This issue has arisen for several people in the past but the solutions for their issues have not worked for me and I have tried alot!
In Wordpress I have created 3 custom post types. 1 for 'videos', 'news' and 'music' and each of these post to their own page. I want to add custom fields so I can have 'artist' 'year of release' 'featuring' and 'about the album' for the music posts for instance.
I have installed Advanced Custom Fields and I can add custom fields to each of these so when the user clicks 'add new' the fields are visible. But the issue I have is that the output of these fields is not displaying on the site when I visit the page.
I created news.php, music.php and videos.php from the single.php file with the following:
<?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(); ?>
And in functions.php I have the following:
/*---------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' );
Does anyone know what I am missing to get this working or what I need to do.
Any suggestions much appreciated.