[Resolved] Enable tags for pages

Home Forums Support [Resolved] Enable tags for pages

Home Forums Support Enable tags for pages

  • This topic has 3 replies, 2 voices, and was last updated 2 years ago by Leo.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #908973

    Dear generatepress-team,

    first of all thanks for developing such a great theme!

    My request: I would like to enable tags for pages without creating an archive page for them.

    – I’ve informed myself on CPTs as well and in this case tags would be more handy for me.
    – I’m aware that there are also plugins for my request, but I try limiting the plugin usage.
    – My goal is to add tags to pages in a way that I can configure consistent display rules for different page templates (hero sections for instance) + for related posts queries – the used page builder is elementor -> so in short: the tags should just work in the background to establish relationships between different pages.

    So after my “research” I have found the following snippet, that I would like to add to my child theme’s function php – to be safe I would be glad if you could have a look on the code before I implement it:

    // add tag support to pages
    function tags_support_all() {
    register_taxonomy_for_object_type(‘post_tag’, ‘page’);

    // ensure all tags are included in queries
    function tags_support_query($wp_query) {
    if ($wp_query->get(‘tag’)) $wp_query->set(‘post_type’, ‘any’);

    // tag hooks
    add_action(‘init’, ‘tags_support_all’);
    add_action(‘pre_get_posts’, ‘tags_support_query’);

    A short description of what the different parts of the code are doing would also be awesome.

    Thanks a lot and best regards from Germany,

    Customer Support

    Hi there,

    Things like tags and categories are all handled by WordPress itself and GP doesn’t interfere with them at all.

    I would recommend going ahead to try the code and see if it works for you – if it works for default WP twenty-series themes, it should work with GP.

    If not then plugin route might be a good idea as well – Code is code, doesn’t matter whether it’s added as a plugin or added as separate functions as what you have above, they are still code.

    Let me know ๐Ÿ™‚


    Hi Leo,

    thanks for your reply. At the end I’ve opted for the plugin cpt ui and it does an awesome job.

    Have a nice day!

    Customer Support
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.