How to count items of meta query?

$query->found_posts may be what you are looking for from the code reference: https://developer.wordpress.org/reference/classes/wp_query/ Note that meta_query expects nested arrays, even if you only have one query. You may need to use: $meta_query[0][] = array( ….. You should also take care with the form of the original query. If there are one or more relations defined, … Read more

Get_term_meta() does not work with pre_get_posts()

I finally, finally figured it out! I was not able to get the category id in the first place. Strangely, get_query_var(‘cat’) is not working. Here is the way that worked for me, in case someone else also struggles with this: function my_new_category_order( $query ) { $category = get_queried_object(); $cat_id = $category->term_id; $post_order = get_term_meta($cat_id, ‘post-order’, … Read more

WP meta_query args not working in function

You’re very close to it just need to to modify your code little bit. See I’ve update code for you. function my_super_filer_function2($query_args){ global $post; $post_author = $post->post_author; $query_args[‘author’] = $post_author; $query_args[‘post_status’] = array(‘publish’, ‘future’); $query_args[‘meta_query’] = array( array( ‘key’ => ‘zobrazitnatridy’, ‘value’ => ‘Ne’, ‘compare’ => ‘!=’ ) ); return $query_args; } add_filter(‘my_super_filter2’, ‘my_super_filer_function2’);

WordPress meta query not working

When using LIKE clause, you should be using % to the start and end of the value to make it match with the existing values. So your query should look like this. add_action( ‘pre_get_posts’ , ‘my_pre_get_posts’ ); function my_pre_get_posts( $query ) { $value=”%”.$_GET[‘s’].’%’; if( $query->is_main_query() && $query->is_search() ) { $query->set( ‘meta_query’, array( array( ‘key’ => … Read more

Get unique post by meta value using wp_query

You can simply limit the query to return only one result. To achieve this, use the field posts_per_page in your query arguments. Check the documentation for more info on this. $args = [ ‘cat’ => ’44’, ‘posts_per_page’ => ’16’, ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘meta_query’ => [ ‘metavalue1’ => [ ‘key’ => ‘Meta_value’, ‘value’ … Read more

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