custom post type taxonomy “tag” archive : no post found

Tag and Category archive queries default to querying only the post post type, to add your custom post type to those queries, you can use the pre_get_posts action: function wpa_cpt_tags( $query ) { if ( $query->is_tag() && $query->is_main_query() ) { $query->set( ‘post_type’, array( ‘post’, ‘object’ ) ); } } add_action( ‘pre_get_posts’, ‘wpa_cpt_tags’ );

get term archive url / link

Use get_term_link e.g. to print out a list of actors terms linking to the archives: $terms = get_terms(‘actors’); echo ‘<ul>’; foreach ($terms as $term) { echo ‘<li><a href=”‘.get_term_link($term).'”>’.$term->name.'</a></li>’; } echo ‘</ul>’; However! If what you really mean is the equivilant of the custom post type archive, that lists all the posts of that type, but … Read more

Permalink Structure for Multiple Post Type Archives by Taxonomy

Here is part of the code from one of my projects to setup a similar structure for permalinks (same base slug for both the post type and the taxonomy archives), please note the values of ‘has_archive’ and ‘rewrite’ parameters of both the post type and the taxonomy: add_action( ‘init’, ‘register_my_post_types’ ); function register_my_post_types() { register_post_type( … Read more

Filtering a custom post type by custom taxonomy in archive template

Let say you have “book” post type and “genre” taxonomy. And you want to get books with genre of “scifi”. You can pass the parameter in the url using: ?taxonomy=genre&term=scifi Then you can get those parameter using get_query_var(‘taxonomy’) and get_query_var(‘term’) and add them to the WP_Query arguments. $taxonomy = get_query_var(‘taxonomy’); $term = get_query_var(‘term’); $args = … Read more

How to share category taxonomy with custom post type (The Event Calendar plugin)

You can use register_taxonomy_for_object_type() to use a taxonomy with a post type, without having to touch the post type registration code, example: function wpa_categories_for_events(){ register_taxonomy_for_object_type( ‘category’, ‘tribe_events’ ); } add_action( ‘init’, ‘wpa_categories_for_events’ ); To have events appear on the category pages, I believe you have to modify the default category queries via pre_get_posts to add … Read more

Loop through custom taxonomies and display posts

I thought I would provide another answer as the above one is a little hacky, also I added another layer that gets all taxonomies for a post_type. $post_type=”post”; // Get all the taxonomies for this post type $taxonomies = get_object_taxonomies( (object) array( ‘post_type’ => $post_type ) ); foreach( $taxonomies as $taxonomy ) : // Gets … Read more