Home > database >  I want to use post title with custom words as tag in wordpress
I want to use post title with custom words as tag in wordpress

Time:11-01

I want to use post title with custom word as tag in wordpress for all posts. For example, I have the title "How to Create a Post in WordPress" and I would like the tag to look like "How to Create a Post in WordPress guide", "guide" is my word that I would like to add to each tag along with the name of the post. I have about 500 posts and would like to automatically add a tag with the post name my custom word to all posts

I found something like this, but I don't know how to modify it to add a custom word to the post title

I want to use post title as tag in wordpress. Is there anyway to automate the process instead of copy and paste one by one?

CodePudding user response:

Use the code from the other question, and replace this:

wp_set_post_tags( $post_id, $post_title, true );

with this:

$tag_title = $post_title . ' Guide';
wp_set_post_tags( $post_id, $tag_title, true );

CodePudding user response:

Thank you! That's exactly what I meant

  • Related