这个问题已经出现了几个人过去,但对于他们的问题解决方案并没有为我工作,我有很多的尝试!
在WordPress的我已创建3种自定义日志类型。 1“视频”,“新闻”和“音乐”和每一个岗位,以自己的页面。 我想添加自定义字段,所以我可以有“艺术家”发布的“年”“特色”和“关于册”为实例的音乐帖子。
我已经安装了先进的自定义字段,我可以添加自定义字段到每一种这样当用户点击“添加新”领域都可见。 但我有问题是这些领域的输出不会显示在网站上,当我访问该网页。
我创建news.php,从下面的single.php中文件music.php和videos.php:
<?php
/**
* Template Name: music Page
*
* Selectable from a dropdown menu on the edit page screen.
*/
get_header(); ?>
<div id="primary" class="site-content">
<div id="content" role="main">
<?php query_posts( 'post_type=music'); ?>
<?php the_meta(); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
而在functions.php的我有以下几点:
/*---------music Custom Post Types---------------------------------*/
function my_custom_post_music() {
$labels = array(
'name' => _x( 'music', 'post type general name' ),
'singular_name' => _x( 'music', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New music' ),
'edit_item' => __( 'Edit music' ),
'new_item' => __( 'New music' ),
'all_items' => __( 'All music' ),
'view_item' => __( 'View music' ),
'search_items' => __( 'Search music' ),
'not_found' => __( 'No music found' ),
'not_found_in_trash' => __( 'No music found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'Music'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our music and music specific data',
'public' => true,
'menu_position' => 15,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'music', $args );
}
add_action( 'init', 'my_custom_post_music' );
function my_taxonomies_music() {
$labels = array(
'name' => _x( 'music Categories', 'taxonomy general name' ),
'singular_name' => _x( 'music Category', 'taxonomy singular name' ),
'search_items' => __( 'Search music Categories' ),
'all_items' => __( 'All music Categories' ),
'parent_item' => __( 'Parent music Category' ),
'parent_item_colon' => __( 'Parent music Category:' ),
'edit_item' => __( 'Edit music Category' ),
'update_item' => __( 'Update music Category' ),
'add_new_item' => __( 'Add New music Category' ),
'new_item_name' => __( 'New music Category' ),
'menu_name' => __( 'music Categories' ),
);
$args = array(
'labels' => $labels,
'hierarchical' => true,
);
register_taxonomy( 'music_category', 'music', $args );
}
add_action( 'init', 'my_taxonomies_music', 0 );
/*---------news Custom Post Types---------------------------------*/
function my_custom_post_news() {
$labels = array(
'name' => _x( 'news', 'post type general name' ),
'singular_name' => _x( 'news', 'post type singular name' ),
'add_new' => _x( 'Add New', 'book' ),
'add_new_item' => __( 'Add New news' ),
'edit_item' => __( 'Edit news' ),
'new_item' => __( 'New news' ),
'all_items' => __( 'All news' ),
'view_item' => __( 'View news' ),
'search_items' => __( 'Search news' ),
'not_found' => __( 'No news found' ),
'not_found_in_trash' => __( 'No news found in the Trash' ),
'parent_item_colon' => '',
'menu_name' => 'News'
);
$args = array(
'labels' => $labels,
'description' => 'Holds our news and news specific data',
'public' => true,
'menu_position' => 10,
'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'comments' ),
'has_archive' => true,
);
register_post_type( 'news', $args );
}
add_action( 'init', 'my_custom_post_news' );
有谁知道我缺少得到这个工作或我需要做什么。
任何建议非常赞赏。