Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other Post Slug to Tag Re: Post Slug to Tag

#138774
manonatelier
Member

Had to revise code to this, but would appreciate any input. Thank you!

function slug_to_tag($post_ID) {
$gpt = get_post($post_ID);
$sluggish = $gpt -> post_name;
$pattern = ‘/-/’;
$replacement = ‘, ‘;
$sluggies = preg_replace($pattern, $replacement, $sluggish);
wp_set_post_terms($post_ID, $sluggies, ‘post_tag’, true);
}

add_action(‘save_post’, ‘slug_to_tag’);