Adding Categories to Custom Post Type
-
I’m using the Custom Post Type UI plugin and created a taxonomy for the Events post type already built in the Lindeza Pro theme since I want to be able to categorize each Event under the Class taxonomy. I created a taxonomy-class.php to hopefully show the posts of ONLY that category/taxonomy but it shows ALL of the Events (aka Classes) posts. I believe it’s because of the theme’s custom loop used to pull from Events:
<?php $lindeza_get_list_events = lindeza_get_list_events(-1); while ( $lindeza_get_list_events->have_posts() ) { $lindeza_get_list_events->the_post(); ?>
Could anyone direct me on what I need to edit below to get it working? Or a better way to give Events categories other than the method I did? Below is the full code of taxonomy-class.php:
<?php /** * The template for displaying all classes. * Template Name: Classes * @package Lindeza */ get_header(); ?> <header> <div class="page-title"> <div class="wrapper"> <?php if(function_exists('bcn_display')) { ?> <div class="breadcrumbs"> <?php bcn_display(); ?> </div> <?php } ?> <h2><?php printf( __( 'Classes: %s', 'lindeza' ), '<span>' . single_cat_title( '', false ) . '</span>' ); ?></h2> </div> </div> </header> <div class="mainContainer events-page"> <div class="content"> <div class="wrapper"> <div class="content-events"> <div class="events-posts"> <?php $lindeza_get_list_events = lindeza_get_list_events(-1); while ( $lindeza_get_list_events->have_posts() ) { $lindeza_get_list_events->the_post(); ?> <?php get_template_part( 'partials/content', 'events' ); ?> <?php } wp_reset_query(); ?> <div class="pagination"> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } ?> </div> </div> <?php get_sidebar(); ?> </div> </div> </div> </div> <?php get_footer(); ?>
It can be seen in action at https://rebeccalowe.physio/rebecca-lowe/classes/ and in the right sidebar are the class categories (which changes to the default blog sidebar after click through – but I need it to stay as the custom Classes sidebar).
- The topic ‘Adding Categories to Custom Post Type’ is closed to new replies.