Conditional posts in WP_query for search

What about removing the if statement, and combining the queries into something like this: ‘meta_query’, array( ‘relation’ => ‘OR’, array( array( ‘relation’ => ‘AND’, array( ‘key’ => ‘am_get_recurring_count’, ‘compare’ => ‘=’, ‘value’ => ‘0’, ), array( ‘relation’ => ‘OR’, array( ‘key’ => ‘am_enddate’, ‘compare’ => ‘>=’, ‘value’ => $currentdate, ), array( ‘key’ => ‘am_enddate’, ‘compare’ … Read more

Query Posts that have or don’t have a meta_value and order by the same ASC

You can do this by naming index of meta query, then passing array of these names in orderby parameter $args = array( ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => ’10’, ‘meta_query’ => array( ‘relation’ => ‘OR’, ‘with_time’ => array( ‘key’ => ‘TIME_meta_key’, ‘compare’ => ‘EXISTS’ ), ‘without_time’ => array( ‘key’ => ‘TIME_meta_key’, ‘compare’ => … Read more

meta_query ‘compare’ => ‘!=’ not working

try this second query $c_client_args = array( ‘post_type’ => ‘clients_testimonials’, ‘posts_per_page’ => 999, ‘order’ => ‘ASC’, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘c_client_feature’, ‘compare’ => ‘NOT EXISTS’ ), array( ‘key’ => ‘c_client_feature’, ‘value’ => ‘on’, ‘compare’ => ‘NOT IN’ ), ) );

Attachment Metadata inside of Loop

Here’s the fix. All the attachment info is now being called inside the php using wp_prepare_attachment_for_js and the info will load for each image in the loop, to display in the photo gallery. It works now. <?php $the_query = new WP_Query(array( ‘post_type’ => ‘attachment’, ‘post_status’ => ‘inherit’, ‘category_name’ => ‘arch’ )); while ( $the_query->have_posts() ) … Read more

How to sort posts according to meta value?

‘meta_key=keyname’ must also be present in the query so I think you’d want $args = array( ‘meta_query’ => array( array( ‘key’ => ‘wpcf-stream’, ‘value’ => $_POST[‘category’], ‘compare’ => ‘=’ ) ), ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘wpcf-stream’, ‘post_type’ => ‘half-day-course’, ‘posts_per_page’ => 100, ‘order’ => ‘ASC’ ); to display the rest of the posts I’d … Read more

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