Home › Forums › Backend Issues (wp-admin) › Post Object filter on edit Taxonomy page › Reply To: Post Object filter on edit Taxonomy page
Hi Elliot,
I’ve been having a look and don’t know if I’ve got something wrong with it but can’t access the global $current_screen, get_current_screen() returns null and the $_GET array is empty when I run them from within the filter. The $post term passed to the filter is also null.
I’m going round in circles a bit here.
function mo_acf_available_posts( $args, $field, $post )
{
global $wp_query;
global $page_now;
$term = '1'; // WORK OUT HOW TO GET ACTIVE TERM
$args['client'] = $term;
var_dump($args);
echo "<hr>";
var_dump($field);
echo "<hr>";
var_dump($wp_query);
echo "<hr>";
var_dump($page_now);
echo "<hr>";
var_dump($_GET);
echo "<hr>";
return $args;
}
//add_filter('acf/fields/post_object/query/name=excluded_projects', 'mo_acf_available_posts', 10, 3);
This filters the posts by the client term id=1, I just need to get the current term ID and exchange the hard-coded 1 in.
Here’s the vars dumped by the server for each:
$args:
array(7) { ["numberposts"]=> int(-1) ["post_type"]=> string(7) "project" ["orderby"]=> string(5) "title" ["order"]=> string(3) "ASC" ["post_status"]=> array(5) { [0]=> string(7) "publish" [1]=> string(7) "private" [2]=> string(5) "draft" [3]=> string(7) "inherit" [4]=> string(6) "future" } ["suppress_filters"]=> bool(false) ["client"]=> string(1) "1" }
$field:
array(18) { ["key"]=> string(19) "field_52f3bb5c778f0" ["label"]=> string(17) "Excluded Projects" ["name"]=> string(27) "fields[field_52f3bb5c778f0]" ["_name"]=> string(17) "excluded_projects" ["type"]=> string(6) "select" ["order_no"]=> int(1) ["instructions"]=> string(0) "" ["required"]=> int(1) ["id"]=> string(27) "acf-field-excluded_projects" ["class"]=> string(11) "post_object" ["conditional_logic"]=> array(3) { ["status"]=> int(1) ["rules"]=> array(1) { [0]=> array(3) { ["field"]=> string(19) "field_52f3b64ed5d5c" ["operator"]=> string(2) "==" ["value"]=> string(1) "1" } } ["allorany"]=> string(3) "all" } ["post_type"]=> array(1) { [0]=> string(7) "project" } ["taxonomy"]=> array(1) { [0]=> string(3) "all" } ["allow_null"]=> int(0) ["multiple"]=> int(1) ["field_group"]=> int(149) ["value"]=> string(0) "" ["choices"]=> array(0) { } }
$wp_query:
object(WP_Query)#158 (51) { ["query"]=> NULL ["query_vars"]=> array(0) { } ["tax_query"]=> NULL ["meta_query"]=> bool(false) ["date_query"]=> bool(false) ["queried_object"]=> NULL ["queried_object_id"]=> NULL ["request"]=> NULL ["posts"]=> NULL ["post_count"]=> int(0) ["current_post"]=> int(-1) ["in_the_loop"]=> bool(false) ["post"]=> NULL ["comments"]=> NULL ["comment_count"]=> int(0) ["current_comment"]=> int(-1) ["comment"]=> NULL ["found_posts"]=> int(0) ["max_num_pages"]=> int(0) ["max_num_comment_pages"]=> int(0) ["is_single"]=> bool(false) ["is_preview"]=> bool(false) ["is_page"]=> bool(false) ["is_archive"]=> bool(false) ["is_date"]=> bool(false) ["is_year"]=> bool(false) ["is_month"]=> bool(false) ["is_day"]=> bool(false) ["is_time"]=> bool(false) ["is_author"]=> bool(false) ["is_category"]=> bool(false) ["is_tag"]=> bool(false) ["is_tax"]=> bool(false) ["is_search"]=> bool(false) ["is_feed"]=> bool(false) ["is_comment_feed"]=> bool(false) ["is_trackback"]=> bool(false) ["is_home"]=> bool(false) ["is_404"]=> bool(false) ["is_comments_popup"]=> bool(false) ["is_paged"]=> bool(false) ["is_admin"]=> bool(false) ["is_attachment"]=> bool(false) ["is_singular"]=> bool(false) ["is_robots"]=> bool(false) ["is_posts_page"]=> bool(false) ["is_post_type_archive"]=> bool(false) ["query_vars_hash"]=> bool(false) ["query_vars_changed"]=> bool(true) ["thumbnails_cached"]=> bool(false) ["stopwords":"WP_Query":private]=> NULL }
This doesn’t look right, lots of false values and no information, think this might be why I can’t get the $_GET var.
$pagenow:
NULL
$_GET:
array(0) { }
I may well be doing something stupid here but thought I’d post up the code in case someone else can see what I need to do, any advice would be great. Thanks,
Danny
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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.