Articles of wp query

WP_Query with multiple orderby NOT working with ASC and DESC, what's wrong?

I have a query with multiple orderby params in a custom page that I am having difficulty getting to work. The query is to return posts with either tag-AAA or tag-BBB tags. And I’d like to sort it based on DESC order by post_date but within the same pub day sort by post title in […]

How to make Meta Query case sensitive?

I have a meta query similar to: $posts = new WP_Query( ‘post_type=article&meta_key=kln_aid&meta_value=’ . $aid ); where I need aid to be case-sensitive. Is that possible via Meta Query?

Can I simplify in function column_default use of queries

In below function column_default I have several cases doing almost the same query. Is it possible to use only 1 query for all the 3 cases? And if so how do I use it in below example? Thanks for helping me. function column_default($item, $column_name){ global $wpdb; /* if ( ! in_array( $column_name, [‘id’, ‘user_id’, ‘user_email’, […]

Only Get A Certain Number of Posts From WP_Query

I’m not sure what I’m doing wrong. None of my WP_Queries are returning the given number of posts. From what I can tell, it’s returning all of them. How do I fix this? Here is the code I’m currently using for my loops: <?php wp_reset_query(); ?> <?php $review = new WP_Query(array( “posts_per_page” => 1, “category_name” […]

How to exclude a category name from showing?

So I’m trying this code: <?php global $post; $my_query = new WP_Query(‘showposts=8&category_name=featured’); while ($my_query->have_posts()): $my_query->the_post(); $do_not_duplicate = $post->ID; $category = get_the_category(); $content = get_the_content(); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , ‘main-thumbs’); $tn_id = get_post_thumbnail_id($post->ID); $img = wp_get_attachment_image_src($tn_id, ‘main-thumbs’); $width = $img[1]; $height = $img[2]; ?> …. <div class=”cat-square <?php echo esc_html($category[0]->slug) ?>”> with this, I can style […]

Wp_query with 2 meta keys and array of meta values

Hi in my post_type=shop i have 2 meta keys and array of values Custom fields Name Values cu_status pending,processing,completed cu_date 12-Jan-2016 , 13-Jan-2016, …… any date in the same format date(“d-M-Y”) Now i need to loop through all posts with cu_status =pending,processing and cu_date is between 12-Jan-2016 to 13-Apr-2016 What will the query ? Iam […]

WPQuery calling specific posts problem

When I change the order of the posts in the array, the order they appear on the page stays the same. If I delete pages from the array they also disappear. Trying to change order they are displayed but it ain’t happening. Any ideas? <?php $args = array( ‘post_type’ => ‘page’, ‘post__in’ => array(69,67,59) ); […]

WP Query – filtering terms with regex

is there a possibility of filtering posts by terms using regexp? My code doesn’t quite seem to work. $tax[] = [ ‘taxonomy’ => ‘tax_name’, ‘field’ => ‘name’, ‘terms’ => $name, ‘operator’ => ‘REGEXP’, ]; The $tax variable is then properly added to WP_Query args.

Get term by custom term meta and taxonomy

How to get term by custom term meta and taxonomy or how to filter tax_query by term meta instead slug/id? function custom_pre_get_posts($query) { global $wp_query; if ( !is_admin() && is_shop() && $query->is_main_query() && is_post_type_archive( “product” )) { $term = ???get_term_by_meta_and_taxonomy???(‘custom_meta_term’,’my_taxonomy’); $t_id = $term[‘term_id’]; $tax_query = array ( array ( ‘taxonomy’ => ‘my_taxoomy’, ‘field’ => ‘id’, […]

How to provide meta_key array to wp_query?

I’m trying to build a wp_query, so far I’ve managed to get desired result using following query. $args = array( ‘meta_query’ => array( ‘relation’ => ‘OR’, array( //check if meta key exists ‘key’ => ‘youtube-1’, ‘compare’ => ‘=’, ), array( //or not exists ‘key’ => ‘youtube-1’, ‘compare’ => ‘NOT EXISTS’ ) ), ‘orderby’ => ‘meta_value_num’, […]