<section>
<p>wordpress插件</p>
<p>A WordPress Post Series plugin enables you to organize your posts serially to create a book or a course. It provides users a path for learning. Posts series plugins can also be used to split a long post into multiple parts.</p>
<p> WordPress Post Series插件使您可以按顺序组织帖子以创建一本书或一门课程。 它为用户提供了学习的途径。 帖子系列插件还可用于将长帖子分成多个部分。 </p>
<p>In this tutorial, I’ll show you how to create a plugin for displaying a series of posts. You can also integrate the same code into a theme, as theme functionality.</p>
<p> 在本教程中,我将向您展示如何创建一个用于显示一系列帖子的插件。 您还可以将相同的代码作为主题功能集成到主题中。 </p>
<h2> 分类与邮政系列 <span style="font-weight: bold;">(</span>Taxonomies Versus Post Series<span style="font-weight: bold;">)</span></h2>
<p>In WordPress, taxonomies are used to group or organize similar posts together. But WordPress doesn’t provide a way to display all the posts of a particular taxonomy in a customized, serial manner. WordPress taxonomies are displayed using an <code>archive.php</code> file, so we cannot create a post series as a single, indexable post.</p>
<p> 在WordPress中,分类法用于将相似的帖子分组或组织在一起。 但是WordPress没有提供一种以自定义,串行方式显示特定分类法的所有帖子的方法。 WordPress分类法是使用<code>archive.php</code>文件显示的,因此我们不能将帖子系列创建为单个可索引的帖子。 </p>
<p>So we need a post series, which is actually one post that contains other posts in a serial manner.</p>
<p> 因此,我们需要一个帖子系列,它实际上是一个帖子,其中包含一系列按顺序排列的其他帖子。 </p>
<h2> 如何创建帖子系列 <span style="font-weight: bold;">(</span>How to Create a Post Series<span style="font-weight: bold;">)</span></h2>
<p>There are many different ways to create a post series. Popular post series plugins found at WordPress.org use custom taxonomies on WordPress posts to create a post series, but in this tutorial I’ll use Custom Post Types instead.</p>
<p> 创建帖子系列有很多不同的方法。 在WordPress.org上找到的流行的帖子系列插件使用WordPress帖子上的自定义分类法来创建帖子系列,但是在本教程中,我将改用“自定义帖子类型”。 </p>
<h2> 插件文件结构 <span style="font-weight: bold;">(</span>Plugin File Structure<span style="font-weight: bold;">)</span></h2>
<p>Create a plugin directory named <code>sitepoint-post-series</code> and place two files in this, named <code>sitepoint-post-series.php</code> and <code>sitepoint-post-series.css</code>.</p>
<p> 创建插件目录名为<code>sitepoint-post-series</code>和地方两个文件在此,故名<code>sitepoint-post-series.php</code>和<code>sitepoint-post-series.css</code> 。 </p>
<p>In the <code>sitepoint-post-series.php</code> file, place the code below, so that WordPress recognizes the directory as a plugin and lets you install it.</p>
<p> 在<code>sitepoint-post-series.php</code>文件中,将代码放在下面,以便WordPress将目录识别为插件并允许您安装它。 </p>
<pre class="blockcode" tabindex="0"><code class="language-php"><?php
/*
Plugin Name: SitePoint Post Series
Plugin URI: https://www.sitepoint.com/
Description: This used is used to create a post series.
Version: 1.0
Author: Narayan Prusty
*/</code></pre>
<p>You can also add post series functionality to a theme. In this case, you will need to place all the code referred to in this tutorial, in the theme’s <code>functions.php</code> file.</p>
<p> 您还可以将主题系列后继功能添加。 在这种情况下,您需要将本教程中引用的所有代码放在主题的<code>functions.php</code>文件中。 </p>
<h2> 如何创建帖子系列自定义帖子类型 <span style="font-weight: bold;">(</span>How to Create a Post Series Custom Post Type<span style="font-weight: bold;">)</span></h2>
<p>First, we need to create a custom post type, where each custom post type represents a post series.</p>
<p> 首先,我们需要创建一个自定义帖子类型,其中每个自定义帖子类型都代表一个帖子系列。 </p>
<p>Place the code below in a file called <code>sitepoint-post-series.php</code>:</p>
<p> 将下面的代码放在一个名为<code>sitepoint-post-series.php</code>的文件中: </p>
<pre class="blockcode" tabindex="0"><code class="language-php">function sitepoint_post_series_custom_post_type()
{
register_post_type("sitepoint-postseries", array(
"labels" => array("name" => __("Post Series"), "singular_name" => __("Post Series")),
"public" => true,
"has_archive" => true,
"rewrite" => array("slug"=> "post-series"),
"supports" => array("editor", "title", "excerpt", "thumbnail", "comments"),
"capability_type" => "post",
"publicly_queryable" => true,
"tax |
|