I have created a custom post type called video and a custom taxonomy for the custom post’s categories video_category. taxonomy-video_category.php
is the file that is handling the taxonomy however, it’s never returning any posts even though posts of type video_category exist.
This is the code used to create the taxonomy, can’t seem to find what’s exactly wrong so far:
function taxonomies_video() {
$labels = array(
'name' => _x('Videos Categories', 'taxonomy general name'),
'singular_name' => _x('Video Category', 'taxonomy singular name'),
'search_items' => __('Search Video Categories'),
'all_items' => __('All Video Categories'),
'parent_item' => __('Parent Video Category'),
'parent_item_colon' => __('Parent Video Category:'),
'edit_item' => __('Edit Video Category'),
'update_item' => __('Update Video Category'),
'add_new_item' => __('Add New Video Category'),
'new_item_name' => __('New Video Category'),
'menu_name' => __('Video Categories')
);
$args = array(
'labels' => $labels,
'hierarchical' => true
);
register_taxonomy('video_category', 'video', $args);
}
add_action('init', 'taxonomies_video', 0);
Code used in taxonomy-video_category.php
:
// ...
<?php if ( have_posts() ) : ?>
<div class="entry-content">
<?php while ( have_posts() ) : the_post(); ?>
<?php
get_template_part( 'template-parts/content', 'video_cat' );
?>
<?php endwhile; ?>
</div>
<?php else : ?>
<?php get_template_part( 'template-parts/content', 'none' ); ?>
<?php endif; ?>
// ...