How to Add tag to page of wordpress


I added the following code ( old suggestion dated 2013) then it shows and enabled in admin setting, but the tags doesn’t show up on page.

// 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’);

Please help how to correct the code. I am using wordpress v4.5.2
I do not want to use plugin because most of them are out date and don’t want to see if they are out of business.

Thanks in advance!

This code adds tags functionality to pages but doesn’t actually display them. Did you add the code to your page that actually displays the tags?


Thank you so much for your advsie Webmachine!

Glad to know the code works functionality to the pages. This is my first time to try add tag on pages. The tags always display on post. Don’t know if it is possible to display on page to make sure it is functioning.

I haven’t actually tested the code that you have. I got the impression from your first post that it did have some positive effect in the admin area.

Pages aren’t meant to have tags or categories - that is the job of posts.

Read the documentation on tags in the link that I gave you. It explains how to display the tags for a post. Try it on your page and see if it works.

Okay. Thank you Webmachine!

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.