Support

Account

Home Forums Front-end Issues Change acf_form field label & description based on post type Reply To: Change acf_form field label & description based on post type

  • The problem you would run into is that there is no post ID for a new post and this would be the only way to get the post type.

    If it is for an existing post the you could do

    
    global $post;
    $post_type = get_post_type($post->ID);
    

    But like I said, for a new post this will not work because there is no post ID to get and if you get it you’re probably getting the wrong post ID.

    In this case, I would add my prepare_field hooks directly to the template file where I am including the acf_form() call and have a different filter for each post type where I want to alter the labels and instructions so that I do not need to depend on the global $post value.