meta_query in wp_query not working as expected

It is not working because there is a custom query in the events plugin that adds the posts to be ignored (not returned) when you run WP_Query. See getHideFromUpcomingEvents() method in the-events-calendar/src/Tribe/Query.php. But there is however a filter hook that you can use there to do whatever. See the following sample code: function wpse283031_hide_ids( $ids … Read more

Wp query by 2 meta field – check if they exists / have value

Check the Codex. meta_query accepts an EXISTS comparison. $args = array( ‘post_type’ => ‘somepostype’, ‘meta_query’ => array( array( ‘key’ => ‘fname’.$userid, ‘compare’ => ‘EXISTS’, ), array( ‘key’ => ‘lname’.$userid, ‘compare’ => ‘EXISTS’, ) ) ); $query = new WP_Query( $args ); return $tempquery->found_posts; There is a note that… Note: Due to bug #23268, value is … Read more

wp_query->set for several categories

Try using tax_query: $tax_query = array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 1 ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 2 ), array( ‘taxonomy’ => ‘category’, ‘field’ => ‘id’, ‘terms’ => 3 ) ); $query->set( ‘tax_query’, $tax_query );

custom sort posts in archive/taxanomy page

Put something along these lines in your functions.php: add_filter( ‘pre_get_posts’, ‘custom_get_posts’ ); function custom_get_posts( $query ) { if( is_category() || is_archive() ) { $query->query_vars[‘orderby’] = ‘name’; $query->query_vars[‘order’] = ‘ASC’; } return $query; } reference here (see the second answer)

WP_Query orderby not working on custom post_type

OK, I figured it pour reading about Orderby Parameters in WP_Query more carefully. I needed to set votes to meta_key and orderby to meta_value_num: $args = array( ‘post_type’ => ‘entry’, ‘meta_key’ => ‘votes’, ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘DESC’, ‘posts_per_page’ => 10, ‘post_status’ => ‘publish’ ); $loop = new WP_Query($args);

Stylesheet won’t load even when linked

Add the CSS to your child themes style.css file or load it using wp_enqueue_scripts add_action( ‘wp_enqueue_scripts’, ‘wpsites_load_custom_styles’ ); function wpsites_load_custom_styles() { wp_register_style( ‘custom-css’, get_stylesheet_directory_uri() . ‘/your-style.css’, false, ‘1.0.0’ ); wp_enqueue_style( ‘custom-css’ ); } Source

How do I show the post title if an advanced custom field hasn’t been used?

If in doubt, check the documentation first: https://www.advancedcustomfields.com/resources/get_field/ Check if value exists This example shows how to check if a value exists for a field. $value = get_field( ‘text_field’ ); if ( $value ) { echo $value; } else { echo ’empty’; } So, in for your case you would need to use: <?php $short_testimonial … Read more

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