Home › Forums › ACF PRO › Check post type before publishing post › Reply To: Check post type before publishing post
I can’t tell by looking at your code exactly what you’re trying to do, but if all you are doing is setting the post title based on the post type and using values from acf fields and maybe other values, then I would probably use just one acf/save_post filter. ACF passes the post ID and you can use this to get whatever you need.
add_action('acf/save_post', 'your_function_name_here', 20);
function your_function_name_here($post_id) {
if (!is_nemeric($post_id)) {
// post id is not numeric
// it is probably for options, user or term
// no need to go further
return;
}
$post_type = get_post_type($post_id);
// do something based on $post_type;
}
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.