The situation is the following:
The blog as of now has 2200+ posts. In the beginning (2007/2008) I was using manual excerpts where I would put an image and a little bit of text. The manual excerpt (excerpt field populated with an image and text) is shown on archives and wherever wanted.
However recently I decided not to use the manual excerpt (excerpt field populated with an image and text). I switched to the automatic wordpress excerpt, limit the number of words, and fetch the first image in the post (if there is any) wherever I want it. Way more flexibility that way. In order to retain the uniformity of the site I use conditional tag has_excerpt () to adjust or apply new css rules to those posts who have manual excerpt. The conditional tag checks if the post uses the excerpt field (has manual excerpt).
Now I want to remove all manual excerpts (excerpt field populated with an image and text) and in the same time to label those posts (adding tag for example) in order to be able to continue to apply conditional CSS rules for those posts. For example using has_tag ().
I want to do this because those posts have slightly different images than the other posts and I have to apply slightly different CSS rules for them.
Now since there are thousands of posts, it would be insane to go all through them manually. I’m sure there is an easy way to do this via few SQl commands.
- Add tag (or any other label you might think is better) to all posts who have manual excerpts (excerpt field populated with an image and text).
- Delete the content in the excerpt field on all posts.
Some questions are easily solved searching this Stack and joining some answers together.
The following plugin will run the conversion code when activated. Adjust the
$tags
array, and don’t forget to backup your database before proceeding.