Support

Account

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;
    }