To load the selected values from a taxonomy field, you can use the get_field function like so:
$selected = get_field('taxonomy_field_name');
I just looked at the get_posts documentation and the following is very useful:
Note: The category parameter needs to be the ID of the category, and not the category name. Note: The category parameter can be a comma separated list of categories, as the get_posts() function passes the 'category' parameter directly into WP_Query as 'cat'.
So, with that in mind, please edit your taxonomy field and select ‘ID’ as the return format setting. Then you can use the following code:
$selected = get_field('taxonomy_field_name'); $args = array( 'posts_per_page' => 3, 'offset' => 0, 'category' => implode(',',$selected), 'orderby' => 'post_date', 'order' => 'DESC', 'include' => '', 'exclude' => '', 'meta_key' => '', 'meta_value' => '', 'post_type' => 'post', 'post_mime_type' => '', 'post_parent' => '', 'post_status' => 'publish', 'suppress_filters' => true );
Hope that helps.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!