The final code I used was:
<?php
$slides_category = get_field('slider_category');
$args = array(
'post_type' => 'slides_post_type',
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'id',
'terms' => array( $slides_category ),
),
),
);
$slides_loop = new WP_Query( $args );
if( $slides_loop->have_posts() ): while( $slides_loop->have_posts() ): $slides_loop->the_post(); ?>
// Post content goes here
<?php endwhile; ?>
Related Posts:
- Can wp_query return posts meta in a single request?
- Meta query with string starting like pattern
- compare meta_query in get_posts arguments
- Function in array as arguments for WP_Query
- WP_Query to show post from a category OR custom field
- Getting attachments by meta value
- meta_query where value is equal to given value
- Get_post() with meta_key when compare is a date
- querying with custom meta field with meta_query
- Group posts by custom field
- Order by meta_value_num DESC and meta_value ASC on WP 4.0
- getting posts and number by specific meta value in multiple meta
- How to query using a combination of custom_field values?
- Revolution Slider Orderby Two Custom Fields
- WordPress altering my custom query, How to fix it?
- Order by meta_key in custom post type doesn’t affect the query
- How to show only one post for each categories of taxonomy of custom post that contains a specific custom field
- wp_query with multiple custom fields
- Filtering posts by custom field value not working
- Display link to taxonomy archive only if it has posts with certain custom field values
- getting posts and number by specific meta value in multiple meta
- Order Posts by meta value AND published date
- wp_query add arguments using array_push if variable met
- Group WP_Query by meta_key date
- How To Fix WP Query Returns Results But Shouldn’t?
- Get posts for which a custom field is not present, with get_posts
- Output an array of terms for a ‘tax_query’ => array()
- How to Filter Posts by Custom Fields?
- Display custom field meta outside loop, site wide
- Fetch Record based on meta key dates
- Orderby is working with one query but not with other
- Extend product search with meta in WooCommerce
- how to make members list directory through wordpress post custom meta key.
- Query posts without meta preload
- Adding multiple meta_key fields as orderby options to a WP Query via a function
- meta_value_num not ordering all items
- Query all posts if multiple meta key don’t exist
- WP Group posts by year(desc) > month(desc) > date(asc)
- meta_compare not comparing whole integer
- wp_query to print posts if have X custom field value
- wp_query get data from advanced custom field in wordpress
- Why is WP_Query not displaying expected data?
- WP_Query Meta_key is text value and need to sort as numeric not working
- filter wp_query result with custom field values
- Order post type by sum of two custom fields
- How to order posts on each different category?
- Get every post with value in meta key
- Using get_posts to get posts based on a checkbox value with Advanced Custom Fields
- Retrieve select tag custom values from array and display them in current page with wp_query?
- How to use a dropdown to filter posts by custom field
- Order WP_Query results by meta key value in custom query
- Excluding posts with certain value of meta_key keeping posts without that meta_key
- Querying a large number of posts including their custom fields data
- add_query_arg to compare and display events from a certain date
- Comparing 2 Decimal Numbers from custom fields and displaying posts
- Sorting posts by Multiple custom fields in defined order
- Query multiple post types, but different order for each
- Order by the first array within a meta_query
- Query ACF relationship field – Comparator IN – Value array
- How to _GET multiple value checkbox WP_Query in Custom Toxonomy / Custom Fields
- How do i create a custom post query when the meta value is an array?
- How to add a “base” filter for all posts visible to visitors on the site?
- Sort custom post by custom field if none order by latest release
- WP Query – grouping posts by same meta key, adding together values from another key
- Retrieve all custom field values of a specific custom field metakey as an array, inside WP_Query
- meta_query is overriding default search
- Comparing Meta Field date in WPQuery using Meta_Query?
- Getting posts by custom field value
- Order 2 meta_queries differently in WP_Query?
- ACF Post Object meta-query by title not ID
- using custom meta user data to run queries in WordPress
- Order posts by title and custom field value?
- From admin edit user page query either the user_nicename or username field value of the user profile being edited or viewed
- Query by meta value (add a dropdown of all values)
- Order Posts By Custom Field That is an array of objects
- How to create URL parameters to run custom queries?
- List users by Year of Birth using a foreach loop to dynamically populate years and data
- Meta key in wp_query bug?
- Custom WP_query and integrating into theme file
- Query by Category and Custom Field – Shortcode
- Querying posts with meta key and meta value not returning anything
- Sorting posts by meta values: 2 different orders
- WP_Query with Pagination and orderby meta_value_num showing duplicates
- Mathematical operations on custom field values? (updated)
- Compare meta key separation
- WP_Query a custom field value bringing back 0 results
- Sorting Posts with meta value not working
- Order by three custom fields (Y-m-d), then separate into yearly sections
- Loop through multiple custom fields with increasing number
- new WP_query using custom fields
- query_posts with sorting on a custom datestamp
- query post based on comparison
- Query posts filter not working
- Display all custom meta field values from the database using ACF Repeater
- Get posts by meta value except one post [closed]
- Best performance for use Custom Field in WP
- WP_Query sort by ACF date field (newest first) with blank dates first
- How to include custom fields in wordpress search
- Extend search query to search meta keys values based on search string
- How to get products with the same custom attribute like ean code