AI助手支持GPT4.0
Provides a drop-down to select different templates for posts from the post edit screen.
提供一个下拉菜单,用于从帖子编辑屏幕中为帖子选择不同的模板。
The templates are defined similarly to page templates, and will replace single.php for the specified post.
模板的定义类似于页面模板,并且将single.php替换为指定的帖子。
This plugin will NOT switch the templates for the different posts in a listing page, e.g.
此插件不会为列表页面中的不同帖子切换模板,例如
a date or category archive, it will only affect the template used for single posts (i.e. you can choose a template which is not single.php).
日期或类别存档,它只会影响用于单个帖子的模板(即,您可以选择非single.php的模板)。 p>
Post templates, as far as this plugin is concerned, are configured similarly to page templates in
就此插件而言,
帖子模板的配置类似于页面模板
that they have a particular style of PHP comment at the top of them.
他们在顶部具有特定样式的PHP注释。
Each post template must contain the following, or similar, at the top:
每个帖子模板的顶部必须包含以下内容或类似内容: p>
<?php/*/ *Template Name Posts: Snarfer模板名称发布:Snarfer*/* /?>?> code> pre>First note: Page templates use “Template Name:“, whereas post templates use “Template Name Posts:第一注: Page em>模板使用“ 模板名称: em>”,而 post em>模板使用“ 模板名称: em> em>“.em>”。 p>Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-第二个注意事项:您的主题中的自定义帖子模板文件必须与index.php模板文件位于同一目录/文件夹,而子目录中的不是 em>directory/sub-folder.目录/子文件夹。 p>Developers开发人员 h3>If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here's an example below如果要在自定义帖子 type em>上实现自定义帖子 templates em>,则可以使用 cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
<?php/*/ *Template Name Posts: Snarfer模板名称发布:Snarfer*/* /?>?>
/*
/ *
Template Name Posts: Snarfer
模板名称发布:Snarfer
*/
* /
?>
?>
code> pre>
First note: Page templates use “Template Name:“, whereas post templates use “Template Name Posts:第一注: Page em>模板使用“ 模板名称: em>”,而 post em>模板使用“ 模板名称: em> em>“.em>”。 p>Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-第二个注意事项:您的主题中的自定义帖子模板文件必须与index.php模板文件位于同一目录/文件夹,而子目录中的不是 em>directory/sub-folder.目录/子文件夹。 p>Developers开发人员 h3>If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here's an example below如果要在自定义帖子 type em>上实现自定义帖子 templates em>,则可以使用 cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
第一注: Page em>模板使用“ 模板名称: em>”,而 post em>模板使用“ 模板名称: em> em>“.em>”。 p>Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-第二个注意事项:您的主题中的自定义帖子模板文件必须与index.php模板文件位于同一目录/文件夹,而子目录中的不是 em>directory/sub-folder.目录/子文件夹。 p>Developers开发人员 h3>If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here's an example below如果要在自定义帖子 type em>上实现自定义帖子 templates em>,则可以使用 cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
em>“.
em>”。 p>
Second note: You must have the custom post template files in your theme in the same directory/folder as your index.php template file, not in a sub-
第二个注意事项:您的主题中的自定义帖子模板文件必须与index.php模板文件位于同一目录/文件夹,而子目录中的不是 em>directory/sub-folder.目录/子文件夹。 p>Developers开发人员 h3>If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here's an example below如果要在自定义帖子 type em>上实现自定义帖子 templates em>,则可以使用 cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
directory/sub-folder.
目录/子文件夹。 p>
If you want to implement the custom post templates on a custom post type, you can use the cpt_post_types filter, here's an example below
cpt_post_types
如果要在自定义帖子 type em>上实现自定义帖子 templates em>,则可以使用 cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
cpt_post_types code>过滤器,下面是一个示例of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。This code can be added to a plugin or to the functions.php file in your theme.可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
of adding the custom post template selector and metabox to the “Movie” and “Actor” custom post types.
将自定义帖子模板选择器和元框添加到“电影”和“演员”自定义帖子类型中。
This code can be added to a plugin or to the functions.php file in your theme.
functions.php
可以将此代码添加到主题中的插件或 functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
functions.php code>文件中。 p>/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
/** / ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types'); code> pre>
/ ** * Hooks the WP cpt_post_types filter *挂钩WP cpt_post_types过滤器 * * * @param array $post_types An array of post type names that the templates be used by * @param array $ post_types模板使用的帖子类型名称数组 * @return array The array of post type names that the templates be used by * @return array模板使用的帖子类型名称的数组 **/** /function my_cpt_post_types( $post_types ) { 函数my_cpt_post_types($ post_types){ $post_types[] = 'movie'; $ post_types [] ='电影'; $post_types[] = 'actor'; $ post_types [] ='演员'; return $post_types;返回$ post_types;}}add_filter( 'cpt_post_types', 'my_cpt_post_types' );add_filter('cpt_post_types','my_cpt_post_types');
* Hooks the WP cpt_post_types filter
*挂钩WP cpt_post_types过滤器
*
* @param array $post_types An array of post type names that the templates be used by
* @param array $ post_types模板使用的帖子类型名称数组
* @return array The array of post type names that the templates be used by
* @return array模板使用的帖子类型名称的数组
**/
** /
function my_cpt_post_types( $post_types ) {
函数my_cpt_post_types($ post_types){
$post_types[] = 'movie';
$ post_types [] ='电影';
$post_types[] = 'actor';
$ post_types [] ='演员';
return $post_types;
返回$ post_types;
}
add_filter( 'cpt_post_types', 'my_cpt_post_types' );
add_filter('cpt_post_types','my_cpt_post_types');
The plugin is simple to install:
该插件易于安装: p>
custom-post-template
custom-post-template code>目录上传到您的WordPress插件目录 li>Go to the plugin management page and enable the plugin转到插件管理页面并启用插件 li>Upload your post template files (see the Description for details on configuring these), and choose them through the new menu上传您的帖子模板文件(有关配置这些模板的详细信息,请参见“说明”),然后通过新菜单进行选择 li>Give yourself a pat on the back拍拍自己的背 li>
ol>
原文出处:http://www.sanshu.cn/a/9682.html
群主管理都是支付大佬