meta_query only check if both value are set

You can use isset to check if the values are set, and then pass them as arguments. Divide your query by 2 parts and use them as needed. // Check if both are set if ( isset( $max_age ) && isset( $min_age ) ) { $meta_query = array( ‘relation’ => ‘AND’, array( ‘key’ => ‘min_age’, … Read more

WP Query Meta Query

I think the orderby key is at the wrong place. It think it should be like this: $args = array( ‘post_type’ => ‘event’, ‘order’ => ‘ASC’, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘your key to order’, ‘meta_query’ => array( ‘key’ => ‘Date Ordering Format’, ‘relation’ => ‘AND’, array( ‘key’ => ‘Event Type’, ‘value’ => ‘4. take-out … Read more

meta_query is not allowing to show posts when querying multiple arguments in a WP_Query

Try this one <?php $date_today = time(); $args = array( ‘post_type’ => ‘birthday’, ‘posts_per_page’ => 1, ‘meta_query’ => array( ‘relation’ => ‘AND’, array( ‘key’ => ‘field_position’, ‘value’ => ‘Teacher’ ), array( ‘key’ => ‘field_dob’, ‘value’ => $date_today, ‘compare’ => ‘=’, ) ) ); $the_query = new WP_Query($args); if($the_query->have_posts()) : while($the_query->have_posts()): $the_query->the_post(); the_title(); endwhile; endif; ?>

WP_Query to get posts in a specific tag or has post_format

Try Below Code :- $query = new WP_Query(array( ‘posts_per_page’ => 2, ‘tax_query’ => array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-link’ ) ), array( ‘taxonomy’ => ‘space’, ‘field’ => ‘term_id’, ‘terms’ => array(’16’), // 16 is the code for tag longform ‘operator’ => ‘IN’ ) ) ));

Create Shortcode shows only posts with custom_field meta

You need your shortcode to accept attributes. A shortcode with attributes would look like: [publication year=”2017″] Then in your add_shortcode callback function you receive attributes in the first parameter of the function: function wpse_279094_publication_shortcode( $atts ) { echo $atts[‘year’]; } add_shortcode( ‘publication’, ‘wpse_279094_shortcode’ ); You want to be able to account for a user not … Read more

Get meta_query value by user meta array

This should be better for what you’re looking for, the only issue might be how the meta gets returned, as an actual array, or as a string that needs to be turned into an array. $args = array( ‘post_type’ => ‘pictures’, ‘orderby’ => ‘post_modified’, ‘order’ => ‘DESC’ // post_status is unnecessary because default is ‘publish’ … Read more

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