Organizing The Custom Post Type with Taxonomies / Parent Posts

I think it could be a good idea to create two more hierarchical (category like) taxonomies, called Artists and Albums. This way, you’ll be able to query your posts based on taxonomy / term relationships. Basically, what I’m saying is this: Artists -> custom hierarchical taxonomy List item -> custom hierarchical taxonomy Songs -> custom … Read more

Get list of CPT posts in *current* post’s taxonomy term

You can get the Packages of the current Proposal using wp_get_object_terms() and then pass some/all of those into a WP_Query. $terms = wp_get_object_terms( $post_id, ‘packages’, array( ‘fields’ => ‘ids’ ) ); $args = array( ‘post_type’ => ‘proposals’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘packages’, ‘terms’ => $terms ) ), ); $related = new WP_Query( $args … Read more

Calling the first & last post by category in custom post type

It is sometimes irritating that some build-in functions don’t have appropriate filters to modify their output. get_boundary_post() is one of those build-in functions. Unfortunately it does not get posts according to post type, only taxonomy. You can still however make use of this function to get the first and last post. It does support the … Read more

Sorting on Taxonomy in archive page

You did not specify a taxonomy term in tax_query. It should go: ‘tax_query’ => array( array( ‘taxonomy’ => ‘taxonomy_name’, // my guess ‘field’ => ‘name’, ‘term’ => ‘Term name’ ), ), I prefer using ‘field’=>’slug’ in such cases as term names are more likely to be changed. And also change order by ‘title’ to ‘post_title’as … Read more