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

wordpress 插件 文章 2020-04-09 03:50 564 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插件] Checkout Styler for Easy Digital DownloadsCheckout Styler,可轻松进行数字下载
[wordpress插件] Čeština pro WordPressČeština专业版WordPress
[wordpress插件] Saitama Addon Pack玉附加包
[wordpress插件] Coupon Plugin优惠券插件
[wordpress插件] Countdown倒数
随便看看
这样算同一主体吗 425
动态获取到对象数组,怎么展示? 538
企业微信服务商怎么开发行业方案 467
用户登录时提示undefined is not an object? 2070
分包问题 517
wx.getUserInfo获取不到unionId? 642
为什么我小程序的一个页面无法调用任何wxapi,调用都没效果? 590
红包封面审核文件上传无反应 599
红包封面有遇到过突然被领走很多的情况吗? 626
为什么api里不介绍button的绑定时间的参数,例如bindtap,catchtap? 562