I have created a list of custom taxonomies for custom post type 'Movies', here's part of the code:
public function init_post_type()
{
// get label
$labels = array(
'name' => __('Movies', 'tmdb'),
'singular_name' => __('movie', 'tmdb'),
'add_new' => __('Add new movie', 'tmdb'),
'add_new_item' => __('Add new movie', 'tmdb'),
'edit_item' => __('Edit movie', 'tmdb'),
'new_item' => __('New movie', 'tmdb'),
'view_item' => __('View movie', 'tmdb'),
'search_items' => __('Search into movies', 'tmdb'),
'not_found' => __('No movies found', 'tmdb'),
'not_found_in_trash' => __('No movies in trash', 'tmdb')
);
// start formationg arguments
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'has_archive' => true,
'query_var' => true,
'rewrite' => true,
'menu_icon' => TMDB_asset_url( 'images/icon.png' ),
'capability_type' => 'post',
'show_in_menu' => true,
'supports' => array( 'title', 'editor', 'thumbnail', 'comments' )
);
register_post_type( 'movies', $args );
// add taxonomies for this post type
$this->init_taxonomies();
add_action( 'admin_head', array( $this, 'add_32px_icon' ) );
// add meta boxes to "movies" post type
add_action('admin_menu', array($this, 'add_to_menu_metabox'));
// change the layout of movies list
add_filter('manage_edit-movies_columns', array( $this, 'movies_edit_columns' ) );
add_action('manage_posts_custom_column', array( $this, 'movies_posts_columns' ), 10, 2);
}
// Initialize New Taxonomy Labels for the questions custom post type
public function init_taxonomies()
{
$labels = array(
'name' => __( 'Franchises', 'tmdb' ),
'singular_name' => __( 'franchise', 'tmdb' ),
'search_items' => __( 'Search franchise Types', 'tmdb' ),
'all_items' => __( 'All franchise Types', 'tmdb' ),
'parent_item' => __( 'Parent franchise Types', 'tmdb' ),
'parent_item_colon' => __( 'Parent franchise Types:', 'tmdb' ),
'edit_item' => __( 'Edit franchise Types', 'tmdb' ),
'update_item' => __( 'Update franchise Type', 'tmdb' ),
'add_new_item' => __( 'Add New franchise Type', 'tmdb' ),
'new_item_name' => __( 'New franchise Type', 'tmdb' ),
);
// register taxonomy to hold our genre
register_taxonomy(
'franchise',
array('movies'),
array(
'hierarchical' => true,
'query_var' => true,
'show_in_nav_menus' => true,
'labels' => $labels,
'show_tagcloud' => false
)
);
I am displaying those custom taxonomies with this code:
<?php if( isset($the_movie['_tagline']) ) { ?>
<li><span><?php esc_attr_e('Tagline', 'tmdb'); ?>:</span> <?php echo $the_movie['_tagline'];?></li>
<?php } ?>
<?php if( isset($the_movie['_homepage']) ) { ?>
<li><span><?php esc_attr_e('Film website', 'tmdb'); ?>:</span> <a href="<?php echo $the_movie['_homepage'];?>" target="_blank"><?php echo $the_movie['_homepage'];?></a></li>
<?php the_terms( $post->ID, 'regisseur', 'Regisseur: ', ', ', ' ' ); ?><br>
<?php the_terms( $post->ID, 'land', 'Land: ', ', ', ' ' ); ?><br>
<?php the_terms( $post->ID, 'subgenre', 'Subgenres: ', ', ', ' ' ); ?><br>
<?php the_terms( $post->ID, 'stijl', 'Stijl: ', ', ', ' ' ); ?><br>
<?php the_terms( $post->ID, 'streaming', 'Te zien bij: ', ', ', ' ' ); ?><br>
<?php the_terms( $post->ID, 'plot', 'Plot: ', ', ', ' ' ); ?><br>
<?php } ?>
I know i should probably use get_the_term_list, but dit not get that working yet. My problem now lies in the last list of custom taxonomies. They show fine, except on only a few posts, which makes no sense to me.
Here's a link to it working fine:
And here's a link to where to taxonomies do not show up:
Link to post not showing custom taxonomies
Some things i already tried:
- Make sure all custom taxonomy fields for the problem post are filled and posts is saved.
- Use plugin 'show post categories' to try and show the custom taxonomies, i get the same results, most work fine, some do not, they are the same ones.
- Deleted and re-added the post, with the same result, taxonomies not showing.
So i am at a loss here. It just does not make sense. Is it a code problem? A database problem? Wordpress messing up? Any help here would be greatly appreciated.
$post
coming from?