Setting Post Title and Slug from Custom Fields

This topic contains 1 reply and 1 voices, and was last updated by UW 10 years, 5 months ago
Viewing 1 Posts - 1 through 1 (of 1 total)
Author Posts
November 12, 2013 at 2:21 am 9972
UW 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);
?>
November 13, 2013 at 4:15 am 10016
UW UW

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 1 Posts - 1 through 1 (of 1 total)