Support

Account

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! 🥺