The “cat” variable need to be an ID of the category. It depends how you configured the ACF field in the backend.
Maybe you should print_r($selected_cat) to see what’s inside the variable. it is probably an array with the full information of the category.
Related Posts:
- WP query with variables gives no result for specific user
- How can I save the HTML output of a WP_Query function as a variable?
- Replace a single variable with add_filter
- How to send a php var to jQuery Ajax call with two different file
- Nested Queries of decreasing specificity
- get different meta-data of a complicated query at the same time
- Wrong pagination results, page counter resets when navigating
- Unable to display multiple parameters from url by javascript through shortcodes
- Is it possible to order posts using multiple meta queries, i.e. show posts from first meta query, then the second?
- Sending simple variable on single page to WP JSON
- How to exclude meta no index pages from wp_list_pages
- Using a new WP_Query inside the loop
- How to check a variable Changes
- wp_Query with mutuplea values returns all posts
- Load more posts using AJAX based on posts inside WP_Query
- in_array not working on dev server but works on localhost
- wp_query – Exclude the first thumbnail from lazy loading on archives
- meta_query search names when they have middle initials
- How to call my PHP function with AJAX ? wp_query
- WordPress sorting posts by date and title using a dropdown
- Custom search query on WordPress page not working
- global $product is empty string when passed into function
- WP query posts BUT show the most recent and one per author
- Can’t pass var from php wp_ajax into ajax script : result undefined or null
- How to get specific multiple pages excerpts at homepage?
- Ajax filter with loadmore button
- Define global custom post
- Custom global variable not working in function
- How to select post ID for given parent name with nested prepared queries?
- posts_per_page displays only 2 posts instead of 4 posts
- Usermeta data unserialize, extract and display in table in WordPress
- WordPress How do I pass a variable from one add_action to another?
- Use WPQuery to match to specific repeater row in post
- Query by pagename not Working
- Query on a repeater date (acf)
- WP_QUERY post_in problem
- Display featured image of post type category
- how to get data from two different table from wordpress database
- Best way to use variables in multiple functions?
- Trying to add some custom text into WordPress Post title via function.php
- Delete post meta by serialized meta value
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Assign meta_query value to php variable
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- get_filtered_term_product_counts – Get product terms if any products
- Trying to get pagination working on WP_Query() post grid
- Need to show 7 posts from actual date
- How do I fix Undefined variable using $_POST in function?
- Check the database for a postmeta field
- Add code to the header of posts by particular author
- Search for single post by 2 tags
- Paged WP_Query is quitting on page 3
- Getting info about selected posts using one WP_Query
- Get Child of Child Pages in custom Menu
- How to change the value of a variable using input field?
- List all ACF field values across every post on one page
- WordPress search query, how to modify the sql
- Modify post image in full size
- Wp-query output correct, but the loop shows one less item (only sometimes)
- Multiple Arrays for Custom Post Query using Boostrap accordions and ACF repeater fields
- How to display sticky post always at the top (before regular post) in wordpress?
- WP_Query To Display Product Of Brand On Taxonomy Page
- Meta query not showing result properly
- How to find php variable of wordpress theme settings
- Combine multiple queries, array_unique returns nothing
- How to display last whole post on the homepage
- Query to show average # of months all accounts with specific role have been active
- wordpress query returning unexpected results
- Woocommerce Related Product by 2 taxonomy
- Custom Post type Ajax search results
- Help on Wp_query to print an term
- Add class to all meta boxes for a custom post type
- Making list of posts with chosen description
- Query doesn’t display text data with apostrophes
- Ordering / grouping posts by datepicker ACF
- How to return count of items found in SQL query
- Include search tags and users in my search results system
- Display only upcoming events / Show all events when archive year is selected
- Add custom taxonomy to custom search for posts
- making a search.php query
- wp_query beginner
- Passing parameter from the current URL to redirect to another url
- Undefined variable & issue with smof_data
- Querying posts from wordpress with 2 or more conditionals
- Pulling a variable into the wp_nav_menu function
- My query keeps looping infinitely ! how to stop it?
- Efficient way of querying for a “fallback” post?
- Transfer WordPress Login Session to an Extended Webpage on the Same Domain
- SQL Query Search page
- How can I display a query in a page?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- direct query to post_meta table
- For each 3 posts, show a different post type
- Where can I find the declaration of `$_wp_theme_features`?
- Add post class in custom loop (WP_QUERY)
- Child theme functions.php file change database entries
- Only Get A Certain Number of Posts From WP_Query
- Can’t get data from audio media
- Create a hierarchical loop at predefined markup requirements
- Display Year and Month from custom field + Age Calculator