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.
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.