I would recommand to add meta_query in array param, try this
add_shortcode( 'sc_count_brands', 'sc_count_brands_code' );
function sc_count_brands_code($atts) {
$values = shortcode_atts( array('category' => 'Horology',), $atts );
$args = array(
'post_type' => 'brands',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => 'br_category',
'value' => esc_attr($values['category']),
'compare' => '='
),
),
);
$query = new WP_Query( $args );
$countn = $query->found_posts;
$buffer="<span class="magby">Featuring </span><span class="axiac">" . $countn . '</span><span class="magby"> brands</span>';
wp_reset_postdata();
return $buffer;
}
Related Posts:
- Using a custom WP_Query with get_template_part loop
- WP_Query orderby post__in remains ineffective in the Loop [closed]
- How to make WP_Query ‘post__in’ accept an array?
- WP_QUERY Get posts by category and similar name (Like)
- Using get_posts vs. WP_Query
- Is it possible to orderby multiple meta_keys when using meta_value_num?
- Is it possible to wrap Geo Location search around WP_Query?
- Merging multiple wp_query objects
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Using custom meta_query with relation not working as expected
- Nested query inside Logical operator OR not working in meta_query
- SQL Statement generated by WP_Query not producing expected results
- Only show first post to match certain criteria within WP_Query
- What is an efficient way to query based on post_meta?
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Pagination wont work with search results template [duplicate]
- Pagination Not working on Home Page with 2 Query
- WP_Query in a shortcode
- Get all posts without tags
- difference between $wp_the_query and $wp_query? & getting the values properly [duplicate]
- Sort by meta key on archive page
- Custom Field sort not working (WP 3.8.1)
- Get post ID’s from one query and exclude from another
- What are the differences between “Latest Posts” and “Static Page”?
- Retrieve or Query Pages by ID
- WordPress Query is taking more then 20 second and stuck on creating index
- Modifying raw $_POST data early in the lifecycle
- Searching through different categories on different pages code is not working
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Difficulty with rewrite rules
- how to get the id for a post from within a post and return post meta for it
- Show selected images on top in Media Manager
- How to make this WP_Query run faster on a WordPress website?
- How do I sort posts with multiple pages
- Multiple Loops Inside a Function
- Store sticky post’s ids in a transient
- How to use MySQL’s MATCH AGAINST in WP_Query?
- Ajax Pagination on Ajax filter
- Wp_query returning only one post while query through ajax
- Woocommerce query all products and categories
- Add “Category” to Mysql Query
- Can I set my WP_Query to be a Main Query?
- How to use external API content in place of WP posts using $wp_query?
- Make a page return false to is_single() and true for is_post_type_archive() before wp_enqueue_scripts
- category query for pages not working
- Is it possible to set specific posts to show first in a query?
- date_query on draft posts only
- wp_query args adding muitiple tax_querys
- How to get list of posts from permalinks?
- wp_query not working with post_type
- WP_Query posts with comments only
- how to use pre_gets_posts to exclude one queried ID from homepage loop
- Default permalink structure causing Notice: Undefined property: WP_Query::$post
- How to check the array values, what WP_Query has brought to me?
- How to Order a list of taxonomies? orderby?
- Get posts that do not have the same tags as current
- queried_object using pre_get_posts gets notices and warning
- post_parent don’t work and return 0 page
- date_query in pre_get_posts out of memory
- Exclude a Woocommerce product from WP_Query
- WP_QUERY wrong ammount of posts
- How to add sort order to incremented and paginated category loop
- Expecting statement error from php loop using ACF plugin
- Get specific ACF key and value from all posts – no access to DB
- How do I sort this custom list of sticky posts
- Query only displays one page_id
- How to exclude a category name from showing?
- All Posts Have The Same Comments
- Trying to get property of non-object in: $wp_query
- How to set parameters for search loop?
- I am officially missing something about transient posts
- Register Taxonomy – What is `query_var`?
- Get Post ID as a separate RSS feed item
- how to retrieve WP_Query without ordering by date [duplicate]
- Which is from this queries is more faster
- Start Query from 2nd Post without offset
- Related posts by current posts child category
- Trying to change category of wp_query
- Block internal search queries with pre_get_posts and regex rules
- Is it possible to give a classname to specific comments in the WordPress admin?
- How can I have sticky posts while ALSO showing posts from a specific category using one WP_Query?
- Is there documentation for objects returned by WP_Query?
- How to upload 3 attachments to current post?
- In a WordPress multisite configuration, how do I instruct WP_Query() to return posts from a sub-site?
- Custom post type loop error: Trying to get property of non-object
- Search Field that allows options of “Match any keyword” or “Match all keywords”
- WP_Query for posts that have postmeta assigned to a taxonomy
- Paginated Author.php not using Author.php template
- Getting the last X posts, but in ascending order of time
- Help displaying related categories
- Show more than one post on the main page excluding certain category
- How to make a wordpress loop file that displays posts based on certain conditions
- Custom loop – Isolating post meta output depending on current query taxonomy terms
- How do I display posts with specific value in a custom field into my loop?
- Orderby Meta Value and Query from Meta Query
- WP Query to order posts by multiple meta fields
- Order by multiple meta keys on wordpress
- Sort posts in dashboard using custom field; also include posts where field isn’t set
- paginate_links() with Custom Taxonomy
- Output ACF field dynamicaly within a taxonomy loop [closed]