新的"自定义帖子模板"无法加载新的帖子模板列表

时间:2017-04-06 11:18:28

标签: wordpress wordpress-theming custom-wordpress-pages

在WordPress中,我将添加一个自定义帖子类型,名为:MultiMedia
我已经通过CPTUI插件创建了一个自定义帖子类型,并且还粘贴了CPTUI提供的代码,来自"获取代码"菜单到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(); ?>

问题是多媒体不在NewPost侧边栏的DropDown模板列表中,如预期的那样

这是正确的方法吗?
帮我解决这个问题 -Thanks

1 个答案:

答案 0 :(得分:0)

编辑您的代码从
<?php /* Template Name Posts: MultiMedia */ ?>



<?php /* Template name: MultiMedia */ ?>

应该为您解决问题。
有关创建自己的模板的更多信息,请转到this sitehere