Custom Post Type Taxonomy Filters

I would take a look at this page on the Codex: http://codex.wordpress.org/Class_Reference/WP_Query I think you need to override your query_posts() for your landing page, and controlling different queries with if() statements, depending on what areas of a form (guessing you’re using a form?) has filled in. For example: // Carry pagination through $args = array( … Read more

Get posts by term slug only

If you look at source of get_term() it does hard check for taxonomy and for good reasons (caching, collisions, etc). I see two possible approaches: look for term in every appropriate taxonomy until you match try to query for term by search or name__like in multiple taxonomies using get_terms() and work with results

using $wpdb to get custom post type with term

Any suggestions on how to get the title of the first custom post type of ‘property’ with the term ‘Locked’ in the taxonomy ‘status’? $args = array( ‘post_type’ => ‘property’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘status’, ‘field’ => ‘slug’, ‘terms’ => ‘locked’ ) ) ); $your_query = new WP_Query( $args ); while ( $your_query->have_posts() … Read more

Search / Filter posts on Title/Content OR Tags

I worked it out myself.. The query I was looking goes like this: SELECT * FROM $wpdb->posts, $wpdb->term_relationships, $wpdb->term_taxonomy, $wpdb->terms WHERE ($wpdb->terms.name LIKE ‘%$s%’ OR $wpdb->terms.slug LIKE ‘%$s%’ OR $wpdb->posts.post_content LIKE ‘%$s%’ OR $wpdb->posts.post_title LIKE ‘%$s%’) AND $wpdb->posts.ID = $wpdb->term_relationships.object_id AND $wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id AND $wpdb->term_taxonomy.term_id = $wpdb->terms.term_id AND $wpdb->posts.post_status=”publish” AND $wpdb->posts.post_type=”products” ORDER BY $wpdb->posts.post_date … Read more

Alter post order on taxonomy template

I’ve assumed that since the posts have already been returned then I should use ‘query_posts’ to alter the order of the posts. That assumption is wrong. You should pretty much never use query_posts. Use a filter on pre_get_posts. function pregp_wpse_108235( $qry ) { if ( $qry->is_main_query() && $qry->is_tax() ) { $qry->set( ‘order’, ‘ASC’ ); } … Read more

Custom Post Type permalink shows wrong page: homepage/index.php

post_type needs to be max. 20 characters, can not contain capital letters or spaces, in register_post_type(); function your post type name is capitalize Portfolio replace with lower letters portfolio this is my register post type snippet, follow it // add action register our post type portfolio add_action( ‘init’, ‘register_cpt_portfolio’ ); // Register our Custom Post … Read more