Home Forums Plugin Support WP User Frontend Pro Setting Post Title and Slug from Custom Fields

This topic is: resolved

This topic contains 1 reply, has 1 voice, and was last updated by  UW 5 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #9972

    UW
    Participant
    Post count: 1

    I was using code from this post on WordPress Stack Exchange to create my post titles and slugs from custom meta fields for a custom post type on my site. The problem is that when I try to do this with WP User Frontend Pro enabled, it duplicates the post hundreds of times.

    I've tried it with the code below, and also with having wp_insert_post_data as the filter instead of wpuf_update_post_args, but the problem remains. Site is WordPress 3.7.1 and theme is Suffusion 4.4.7.

    function set_people_post_title( $data , $postarr ) {
      if($data['post_type'] == 'people') {
        $first_name = get_post_meta($postarr['ID'],'first_name',true);
        $last_name = get_post_meta($postarr['ID'], 'last_name' , true);
        $people_post_title = $first_name . ' ' . $last_name;
        $post_slug = sanitize_title_with_dashes ($people_post_title,'','save');
        $post_slugsan = sanitize_title($post_slug);
    
        $data['post_title'] = $people_post_title;
        $data['post_name'] = $post_slugsan;
      }
      return $data;
    }
    add_filter( 'wpuf_update_post_args' , 'set_people_post_title', '10', 2);
    ?>
    #10016

    UW
    Participant
    Post count: 1

    Figured it out. Conflict with Relevanssi–fixed settings as per this post in WordPress Support.

    1. Go to Settings > Relevanssi
    2. Halfway down the page you should find Expand shortcodes in post content
    3. Uncheck this

Viewing 2 posts - 1 through 2 (of 2 total)

The topic ‘Setting Post Title and Slug from Custom Fields’ is closed to new replies.