新 "custom post template" 无法加载到新 post 模板列表中
new "custom post template" cant be load in new post template list
我将在 WordPress 中添加自定义 Post 类型,命名为:MultiMedia
我通过 CPTUI 插件创建了自定义 Post 类型,并将 CPTUI 提供的代码从 "Get Code" 菜单粘贴到 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(); ?>
问题是多媒体不在新Post侧边栏中的模板下拉列表中,正如预期的那样
这是正确的方法吗?
帮我解决这个问题
-谢谢
我将在 WordPress 中添加自定义 Post 类型,命名为:MultiMedia
我通过 CPTUI 插件创建了自定义 Post 类型,并将 CPTUI 提供的代码从 "Get Code" 菜单粘贴到 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(); ?>
问题是多媒体不在新Post侧边栏中的模板下拉列表中,正如预期的那样
这是正确的方法吗?
帮我解决这个问题
-谢谢