Support

Account

Forum Replies Created

  • Great, this is the better way inside one function.
    Thanks you, really appreciate.

  • So I just keep adding new functions with every new custom post type?

  • I have more than one custom field, so code looks like this:

    // Get title from acf into post title
    add_action('acf/save_post', 'upd_cust_post_title', 20); // fires after ACF
    function upd_cust_post_title($post_id) {
      $post_type = get_post_type($post_id);
      if ($post_type != 'house') {
        return;
      }
      $post_title = get_field('name', $post_id);
      $post_name = sanitize_title($post_title);
      $post = array(
        'ID' => $post_id,
        'post_name' => $post_name,
        'post_title' => $post_title
      );
      wp_update_post($post);
    }
    
    add_action('acf/save_post', 'upd_car_post_title', 20); // fires after ACF
    
    function upd_ann_post_title($post_id) {
      $post_type = get_post_type($post_id);
      if ($post_type != 'car') {
        return;
      }
      $post_title = get_field('title', $post_id);
      $post_name = sanitize_title($post_title);
      $post = array(
        'ID' => $post_id,
        'post_name' => $post_name,
        'post_title' => $post_title
      );
      wp_update_post($post);
    }
    
    

    Is that’s the way to do it? Or there’s better way?

    Thanks

  • Worked, like a charm. Thanks a bunch, YOU’ve made my day.

  • Thanks, it better now, but I got a weird error:

    Missing PDF “https://mysite.com/uploads/Array”

    Here’s code again

    <?php $pdf = get_field( 'pdf' ); ?>
    <?php if ( $pdf ) { ?>
    
    <?php echo do_shortcode('[pdf-embedder url="'.get_field('pdf').'"]'); ?>
    <?php } ?>
Viewing 5 posts - 1 through 5 (of 5 total)