Jump to content

Scan and auto tag


Peter Knight
 Share

Recommended Posts

Hi guys. Just a query - nothing relevant on Google.

I have about 400 blog posts which need tagging and categorising.

I already have a list of about 5 known words I need tagged and applied to each post via pageselect field.

IE cat, dog, fish

Is it possible to somehow scan my 400 posts body field for these cat, dog, fish words, and then auto-tag them?

Just a query at the moment.

Link to comment
Share on other sites

should not be a problem...

somehow like this:

$tag = $pages->get("/tags/fish/");
$poststotag = $pages->find("body*=" . $tag->title);
foreach($poststotag as $post) {
  $post->of(false);
  $post->tags->add($tag); // tags is the name of your pagefield
  $post->save();
}

no working code and surely full of mistakes but i think the principle should work

maybe you have to check if the post is already tagged...

  • Like 2
Link to comment
Share on other sites

you could write a simple script using strpos on the body and then add tags conditionally;

you could do it all in 1 go with a script such as that (have done a lot of stuff like that when setting up new sites and importing)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...