[wordpress插件] Custom Post Template自定义帖子模板

wordpress 插件 文章 2020-04-09 03:50 563 0 全屏看文

AI助手支持GPT4.0

评分
96
描述

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的模板)。

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:

每个帖子模板的顶部必须包含以下内容或类似内容:

  <?php

/*

/ *

Template Name Posts: Snarfer

模板名称发布:Snarfer

*/

* /

?>

?>

First note: Page templates use “Template Name:“, whereas post templates use “Template Name Posts:

第一注: Page 模板使用“ 模板名称:”,而 post 模板使用“ 模板名称:

em>“.

em>”。

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模板文件位于同一目录/文件夹,而子目录中的不是

directory/sub-folder.

目录/子文件夹。

Developers

开发人员

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 上实现自定义帖子 templates ,则可以使用 cpt_post_types 过滤器,下面是一个示例

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 文件中。

/** 

  / ** 

* 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:

该插件易于安装:

    1. Download the plugin, it will arrive as a zip file
    2. 下载插件,它将以zip文件格式提供

    3. Unzip it
    4. 解压缩

    5. Upload custom-post-template directory to your WordPress Plugin directory
    6. custom-post-template 目录上传到您的WordPress插件目录

    7. Go to the plugin management page and enable the plugin
    8. 转到插件管理页面并启用插件

    9. Upload your post template files (see the Description for details on configuring these), and choose them through the new menu
    10. 上传您的帖子模板文件(有关配置这些模板的详细信息,请参见“说明”),然后通过新菜单进行选择

    11. Give yourself a pat on the back
    12. 拍拍自己的背

下载地址
https://downloads.wordpress.org/plugin/custom-post-template.zip
-EOF-

AI助手支持GPT4.0


国内超级便宜服务器

摸鱼人热门新闻聚合

钻级赞助商 我要加入

开发者在线工具

第三方支付技术请加QQ群

相关文章
[wordpress插件] Coder Customizer Framework编码器定制程序框架
[wordpress插件] Advanced Custom Field: Shortcode Field高级自定义字段:简码字段
[wordpress插件] 404 error &#8211; carrot404错误–胡萝卜
[wordpress插件] Comments-advanced进阶评论
[wordpress插件] Clean Up Zombie Users (spammers)清理僵尸用户(垃圾邮件发送者)
随便看看
微信公众号openid? 2347
微信开放平台跟公众平台有什么区别? 3608
怎么添加小程序支付功能? 4516
教育科技公司申请微信支付被拒绝? 4799
微信公众号免300认证教程 5892
小程序已经上线,作为管理员无法在小程序数据助手查看数据? 5299
小程序广告组件通过审核,但是小程序内没有显示广告? 5067
企业微信通讯录账号被管理员误/恶意删除,怎么办? 9568
问题? 9048
如何快速搭建抽奖助手小程序(无需代码知识) 6177