How To Add Post Tags To Pages

Adding tags to pages in WordPress used to be a simple copy and paste job.

Update : This newer solution also prints your page tags on single pages and adds the single pages to your tag archives.

All you needed to do was paste this code in your child themes functions file.

However, the code only adds the input meta box for post tags and does not display the tag links on single pages or add single pages to tag archive pages.

The code will display a meta box for tags on all Edit Page screens.

page tags metabox

The code uses the register_taxonomy_for_object_type function.

Here’s the official description from the WordPress Codex:

This function adds an already registered Taxonomies to an already registered Post Types. It takes in a name, an object name that it affects. It returns true on success.

In this case the taxonomy already registered is post_tag

The Post Type already registered is page

Why Add Tags To Pages

The reason i wrote this post is because someone wanted to display the featured images & links to specific pages in a slider which uses tags to determine the content which is pulled into the slider.

Once post tags are added to pages, you can then group together the pages and posts you want displayed in your slider.


Comments

4 responses to “How To Add Post Tags To Pages”

  1. Is there any way to modify the action slightly so that I can filter out urls from the tags? I’m using this code and it works perfectly. The only thing I don’t want is the url.

    1. Brad Dalton Avatar
      Brad Dalton

      Should be able to do that yes but would need to write the filter to do it.

  2. Jim Colella Avatar
    Jim Colella

    Hi Brad. I’m using the Genesis Eleven40 Pro theme and I’m currently having problems with this very issue. I would like for the tags to appear on my pages (as they do on the posts). I tried the above code, but the tags did not appear. I have also tried a plugin called ‘Post Tags and Categories for Pages’ which uses the same code as above — except even with that activated, the tags did not appear on the pages, although the categories did appear on the page. FYI, when I used the above code, I deactivated the plugin I just mentioned. I’ve also tried a number of other code snippets on making categories and tags appear on pages, but I have only been successful with making the categories appear on pages. My guess is that there is someting specific within eleven40’s structure blocking tags from showing on pages. But that’s just a wild guess. You’re the expert on this. Any ideas would be much appreciated. Thanks in advance for any clues you can offer.

    1. Brad Dalton Avatar
      Brad Dalton

      Thanks for the question Jim.

      When i tested the code it works on both the back and front end so not really sure why it doesn’t with Eleven40 Pro.

      I also tested on Enterprise Pro just now and the meta box for tags is added in the backend but the tags not displayed on the front end.

      I would post this question on the SP forums and see if someone knows the answer.
      Another option is to use Twitter with the #genesiswp hashtag.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.