get_categories for custom post type with a specific custom taxonomy attached

Hi @daveaspi: What you want to do is common but not well handled in WordPress core. There are probably ways to do it without custom SQL but I don”t think they would scale for a large number of posts. Below is a function I wrote called get_cross_referenced_terms() that will get what you want, complete with … Read more

Category archive by year with permalink support /category/YYYY

What you’re looking for is an endpoint. There are already several of these built in: /feed/some-feed/ for feeds or /trackback/ on posts. Those are both endpoints. Fortunately, WordPress provides a handy function makes adding your own endpionts really easy. add_rewrite_endpoint This is all the code you need to make your yearly category archives work: <?php … Read more

How to remove “Archive:” label from archive title

You need to use the filter get_the_archive_title. It works like the_title filter. More details about the function that embed the filter here More in this question remove category tag EDIT : When it’s a custom post type archive page, you might use another function to print the title : post_type_archive_title() Then you’ll be able to … Read more

How to get the custom post type from an archive page?

There are a several of ways to do this. Put: var_dump($wp_query->query,get_queried_object()); die; In your archive.php and you should see two of those ways. $wp_query->query will have post_type component for custom post types. That will not be there for post post types. get_queried_object will return quite a bit of data for custom post types but null … Read more

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

Adding content to archive and taxonomy pages on custom post types?

First solution can be using the Settings API and create 2 fields “Products Description” and “Usage Description”, after that showing in your template that fields is easy like a: $options = get_option(‘my_theme_options’); echo $options[‘prod_description’]; // echo $options[‘usage_description’]; However, settings API is not the best part of WP core, and probably create a settings page for … Read more