Home › Forums › Backend Issues (wp-admin) › Post Object Field broken when getting $_GET['post'] › Reply To: Post Object Field broken when getting $_GET['post']
Bumping this one as I am completely baffled and it’s really annoying me. Essentially I hook up to after_setup_theme. At this stage I do not know the post ID other than by using $_GET, so this is my code:
$acf_loader = new ACFLoader();
$post_id = $_GET['post'];
$post_type = get_post_type( $post_id );
call_user_func( array( $acf_loader, 'create_' . $post_type . '_fields' ) );
When I do that, all of ACF fields functionality goes out the window (see movie above). If I do this, it works fine:
$acf_loader = new ACFLoader();
$acf_loader->create_volunteer_fields();
$acf_loader->create_client_fields();
$acf_loader->create_match_fields();
$acf_loader->create_area_coordinator_fields();
$acf_loader->create_referrer_fields();
This class merely uses FieldsBuilder to create the fields that are needed.
If I hook up to ‘wp’ or anything else, I am able to query the post but it’s too late for the ACF fields to take effect.
Any pointers appreciated! 🥺
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.