wp_query custom post type by taxonomy & standard post by taxonomy

here is the answer: $args = array( ‘post_type’ => array( ‘artists’, ‘post’ ), ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘tag_artists’, ‘field’ => ‘slug’, ‘terms’ => array( ‘home’ ) ), array( ‘taxonomy’ => ‘post_tag’, ‘field’ => ‘slug’, ‘terms’ => array( ‘home’ ) ) ) ); $query = new WP_Query( $args … Read more

Custom post type and URL

In short – you cannot, or at least should not. www.domain.com/post-title is interpreted as post (if your structure is %postname%) and/or a page – and WordPress is set to deal with them as such, including any conflicts. You can do the following: add_action(‘init’,’wpse0845_add_rule’); function wpse0845_add_rule(){ add_rewrite_rule(“([^/]+)/?”,’index.php?book=$matches[1]’,’top’); } (and then flush rewrite rules, once). However, you’ll … Read more

Display custom post type taxonomy and month

Do a simple meta_query and compare by meta_value_num. array( ‘post_type’ => ‘webcast’, ‘meta_key’ => ‘webcast-date’, ‘meta_value’ => array( time(), strtotime(‘+60 days’) ), ‘meta_type’ => ‘numeric’, ‘meta_compare’ => ‘BETWEEN’, ‘orderby ‘ => ‘meta_value_num’, ‘order’ => ‘ASC’ ); For an easy example. You can find more complex examples on the site filed under meta-query – even more … Read more

Custom Post Order for a Custom Post Type

As it’s not clearly stated, how (in code) the “related” CPTs are interconnected, I want to post a mostly overseen possibility for CPTs. When you register_post_type(), you have the argument of hierarchical that should be set to true to allow for ‘supports’ => array( ‘page-attributes’ ). This then allows you to define an order manually.