WP_Query OR clause for tax_query and keywords

Here’s a little experiment: You can try the following setup: $args = array( ‘wpse_search_or_tax_query’ => true, // <– New parameter! ‘s’ => ‘some search text’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘category’, ‘field’ => ‘slug’, ‘terms’ => array( ‘some-category-slug’ ), ‘operator’ => ‘IN’, ), ), ); $query = new WP_Query( $args ); where we introduce … Read more

Orderby = none not working [duplicate]

Order by none doesn’t do what you think it does. If you don’t specify an order, then MySQL doesn’t guarantee any particular order and will simply get the posts in whatever order it has them. Since they were inserted in a particular order, then you’ll probably get them in that order. Since you need the … Read more

assign 2 $args to one wp_query

array_merge does not work the way you expect/need it to, but honestly I am not sure why you are making this so complicated. All you need is: $args = array( ‘s’ => ‘keyword1 keyword2’, ‘orders’ => ‘DESC’, ‘showposts’ => 60 ); // var_dump($args); // debug $query = new WP_Query($args); var_dump($query->request); // debug The built is … Read more

Numeric pagination custom post type

You’re referencing the global $wp_query object in your function which you’ve reset using wp_reset_query(). You can resolve the pagination by passing your custom $loop WP_Query object to the function. I also changed wp_reset_query to wp_reset_postdata Also you’re making the call to your pagination function in the while loop instead of after it. Your function should … Read more

how to group custom post type posts by custom taxonomy terms

try using this fancy function that group the posts by term id that Scribu and Mike created: function event_clauses( $clauses, $wp_query ) { global $wpdb; if ( isset( $wp_query->query[‘orderby’] ) && ‘event_location’ == $wp_query->query[‘orderby’] ) { $clauses[‘join’] .=<<<SQL LEFT OUTER JOIN {$wpdb->term_relationships} ON {$wpdb->posts}.ID={$wpdb->term_relationships}.object_id LEFT OUTER JOIN {$wpdb->term_taxonomy} USING (term_taxonomy_id) LEFT OUTER JOIN {$wpdb->terms} USING … Read more

Merge 2 args in one WP_Query and order it by date

A better approach could be using three queries. First two query retrieve the post ids, and third one query post by ids. // first query $first_ids = get_posts( array( ‘fields’ => ‘ids’, ‘posts_per_page’ => ’10’, ‘post_status’ => ‘publish’, ‘post_type’ => array(‘news’,’partners’), ‘orderby’ => ‘date’, ‘order’ => ‘DESC’ )); // second query $second_ids = get_posts( array( … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)