Category page only displaying the posts from a custom type

Ok I found a solution by following the recommandation of s_ha_dum to use pre_gets_posts. All the following code goes to functions.php 1 Create a new rewrite rule function rewrite_clean() { // my CPTs $types = array(‘projects’, ‘works’); foreach($types as $type) { add_rewrite_rule(‘^’.$type.’/([^/]*)/?$’, ‘index.php?post_type=”.$type.”&term=$matches[1]’,’top’); } } add_action(‘init’, ‘rewrite_clean’); transform the following format ?post_type=projects&term=architecture to the following … Read more

Taxonomy Url with Custom post type prefix re-write rule

Try changing the $args you are passing into the register_taxonomy method so that rewrite -> slug includes the development tag $args = array( ‘labels’ => $labels, ‘public’ => true, ‘show_in_nav_menus’ => false, ‘show_ui’ => true, ‘hierarchical’ => true, ‘supports’ => array(‘title’, ‘editor’, ‘excerpt’, ‘thumbnail’), ‘rewrite’ => array(‘slug’ => ‘development/section’, ‘with_front’ => true, ‘hierarchical’ => true), … Read more

get_categories() for only CPT

You should use wp_get_post_terms() instead of get_categories(). It returns an array of terms associated with a post. <?php function get_my_custom_terms() { global $post; $myterms = wp_get_post_terms($post->ID, ‘location’); if ($myterms) { foreach($myterms as $term) { $termname = $term->name; $term_link = get_term_link( $term->slug, ‘location’ ); if( is_wp_error( $term_link ) ) { $termlink = $term_link; } else { … Read more

Display Custom Taxonomy

Use the_terms(): the_terms( $id, $taxonomy, $before=””, $sep = ‘, ‘, $after=”” ) So in your loop: if ( ‘radio-shows’ === get_post_type() ) { the_terms( get_the_ID(), ‘genre’ ); the_terms( get_the_ID(), ‘instruments’ ); } else { the_category(); the_tags(); }