How to query custom post type with 3 custom taxonomies linked to it

When registering a post type, always register your taxonomies using the taxonomies argument. If you do not, the taxonomies and post type will not be recognized as connected when using filters such as parse_query or pre_get_posts. This can lead to unexpected results and failures. http://codex.wordpress.org/Function_Reference/register_post_type#Taxonomies Your argument list for register_post_type needs to include: ‘taxonomy’ => … Read more

Filtering WP_Query

I rewrote the code and now it works The loop: $args = array(‘post_type’ => ‘artist’); $wp_query = new WP_Query( array_merge( $args, array(‘nopaging’ => true) ) ); The filter: function theme_posts_orderby( $orderby, $query ) { if ($query->query_vars[‘post_type’] == ‘artist’) { // order artists by last name $orderby = “RIGHT(post_title, LOCATE(‘ ‘, REVERSE(post_title)) – 1) ASC”; } … Read more

Display posts from Custom Post Type in category page on front-end

You are better off separating categories for posts and using custom taxonomy types for CPT categories. You’d add this line to your register cpt code ‘taxonomies’ => array( ‘bizdirectory-type’ ), Replacing this line in your code. ‘taxonomies’ => array( ‘category’ ), And then add this code in your functions.php add_action( ‘init’, ‘wpsites_custom_taxonomy_types’ ); function wpsites_custom_taxonomy_types() … Read more

Making certain categories of CPT not publicly queryable

Sounds like you really just need a filter on pre_get_posts to remove the unwanted terms. Something like this, but I am not sure I understand all the conditions you need so think of it as proof of concept only. function exclude_terms_wpse_117242($qry) { if (is_user_logged_in()) { $tq = array( array( ‘taxonomy’ => ‘your_tax’, ‘field’ => ‘id’, … Read more

Hierarchical Custom Post Types in Array

It seems that you are looking to accomplish is a simple parent/child relationship with *n levels. I ran into something similar when working on subordinate posts https://github.com/codearachnid/wp-subordinate-post. The way I resolved the hierarchy (and even allowed for deep permalinking was to utilize the post_parent field. Based on your statements it seems like there might be … Read more