I'm trying to do this via MySQL, but would love to do it with a plugin.
I want to search/replace (and ideally concat) post content, but only posts that belong in one category.
I can do this which shows all the posts in the category 7266, which is a good:
SELECT DISTINCT ID, post_title, post_name, guid, post_date, post_content
FROM wp_posts AS p
INNER JOIN wp_term_relationships AS tr ON (
p.ID = tr.object_id
)
INNER JOIN wp_term_taxonomy AS tt ON (
tr.term_taxonomy_id = tt.term_taxonomy_id
AND taxonomy = 'category' AND tt.term_id
IN ( 7266 )
)
ORDER BY id DESC
And I can do this which will add a tagline to all posts:
UPDATE wp_posts SET post_content = CONCAT(post_content, 'This is the category tagline')
But how do I combine those two to only add the tagline to posts in category 7266?
PS: I know I can add taglines based on category through PHP, but for a variety of reasons that won't work for what I need. I need to actually edit the content in the database based on category.