ACF field with dynamic filter on category

[ad_1]

I’ve got an acf field which is a post\_object. I’ve got it set to appear on every category page but I’m trying to add a filter hook which only allows posts to appear that are within the category I’m editing. I’ve tried to add the code below but it either doesn’t work, or it produces an error:

​

$tag_id = isset($_GET[‘tag_ID’])
? $_GET[‘tag_ID’] : false;

add_filter(‘acf/fields/post_object/query/name=featured_products’, ‘my_acf_featured_product_filter’, 10, $tag_id);

function my_acf_featured_product_filter($args, $fields, $post_id) {

if ($post_id != false) {
$args[‘post_parent’] = $post_id;

return $args;
}

}

[The ACF Field with the location rules below])

Does anyone know where I can look for more help or if someone has had this issue before and has found a solution I’m not seeing.

​

TIA

[ad_2]

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer