Skip to content
Grav 2.0 is officially stable. Read the announcement →
Support

Deleting certain tags from all pages

admin

Solved by pamtbaau View solution

Started by Kyle Alexander Buan 6 years ago · 2 replies · 692 views
6 years ago

We have a fairly large website with multiple posts, and we would like to remove a certain tag (let's just call it "tag A") from all pages.

For a small amount of pages, we could just do this manually but if there are multiple tags to delete, or the page amount is large, it would become tedious easily.

Can anyone please guide me to do this simpler (for example, using a built-in Admin feature, or using an existing plugin), or if possible, point me to the right direction on how to make this plugin? (Doesn't have to be in code, just general pointers!)

Thanks a lot in advance!

6 years ago Solution

@orthocube, Using a plugin you could try something like:

  • Install devtools if not already: $ bin/gpm install devtools
  • Create new plugin: $ bin/plugin devtools newplugin
  • Create function handling event onPagesInitialized
    • Create a collection based on taxonomy (see example in docs)
    • Loop through pages found
    • Get taxonomy: $tax = $page->taxonomy(); (see Page class)
    • Remove the tag from the array
    • Set taxonomy: $page->taxonomy($tax);
    • Save page: $page->save();
👍 1
last edited 07/30/20 by pamtbaau
6 years ago

This is exactly the guide I've been looking for! I can write code, so it's just the general guideline I needed.

Thank you very much!

It would be awesome if the plugin can be viewed from the Admin page and triggered using buttons and input textboxes, so I'll try my best to find out how to do that.

Thanks again!

Suggested topics

Topic Participants Replies Views Activity
Support · by BenLaKnet, 5 days ago
1 122 2 days ago
Support · by BenLaKnet, 1 week ago
5 195 2 days ago
Support · by kskt, 3 days ago
0 44 3 days ago
Support · by David Meissner, 3 days ago
0 43 3 days ago
Support · by David Meissner, 4 days ago
3 92 3 days ago