Enable Tags on Pages in WordPress

30th July 2014

Reading Time:

It’s easy enough to add tags to posts in WordPress, but the default functionality doesn’t offer tags on pages. Luckily WordPress treats posts and pages pretty much the same, it’s an easy fix to add this to your project.

Open up your functions.php file and insert the following:

    // add tag support to pages
    add_action( 'init', 'tags_support_all');
    function tags_support_all() {
        register_taxonomy_for_object_type('post_tag', 'page');
    // ensure all tags are included in queries
    add_action( 'pre_get_posts', 'tags_support_query');
    function tags_support_query($wp_query) {
        if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');

I stumbled upon this one at Sitepoint, a pretty handy source for helpful WordPress bits n’ bobs.

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *

About the author

Rik Kendell is a developer, designer and writer in Leeds, UK, specialising in responsive WordPress websites. With over 10 years experience in the industry, Rik has worked on award-winning teams at agencies, in-house and as a freelancer. Rik has worked with clients ranging from the NHS, Sky and Skipton Building Society to McDonalds, Lamb’s Navy Rum and Crabbie’s Ginger Beer.

Outside of work Rik is also a keen writer, an amateur woodworker, gamer and foodie. His blog posts, reviews and Tweets have been published by the BBC, the Evening Standard, the Guardian and the Independent. He has written guest posts for a number of agencies and industry websites.