在WordPress中,我将添加一个自定义Post类型,名为: MultiMedia
我通过CPTUI插件创建了自定义Post类型,并将CPTUI提供的代码从"Get代码“菜单粘贴到Funtion.php的末尾:
function cptui_register_my_cpts_multimedia() {
/**
* Post Type: MultiMedia.
*/
$labels = array(
"name" => __( 'MultiMedia', '' ),
"singular_name" => __( 'MultiMedia', '' ),
.
.
.
"attributes" => __( 'MultiMedia Attributes', '' ),
"parent_item_colon" => __( 'Parent MultiMedia:', '' ),
);
$args = array(
"label" => __( 'MultiMedia', '' ),
"labels" => $labels,
.
.
.
"supports" => array( "title", "editor", "thumbnail", "custom-fields" ),
"taxonomies" => array( "category", "post_tag" ),
);
register_post_type( "multimedia", $args );
}
add_action( 'init', 'cptui_register_my_cpts_multimedia' );然后,我在主题文件夹中创建了一个multimedia.php:
<?php /* Template Name Posts: MultiMedia */ ?>
<?php get_header(); ?>
<div class="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
MultiMedia post type is working!
<?php endwhile; ?>
<?php endif; ?>
</div> <!-- end #main -->
<?php get_footer(); ?>问题是多媒体不在DropDown侧边栏中的模板列表中,这是人们所期望的。
这样做对吗?
帮我把这个修好
-thanks
发布于 2017-04-06 11:31:33
编辑您的代码
<?php /* Template Name Posts: MultiMedia */ ?>
至
<?php /* Template name: MultiMedia */ ?>
应该为你做点什么。
有关创建自己的模板的更多信息,请转到本站或这里
https://stackoverflow.com/questions/43253651
复制相似问题