WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Tags for Pages (20 posts)

  1. rajesh0228
    Member
    Posted 4 years ago #

    Hi there, I want to know why the Tags text-box for a Post doesn't exist for a Page? How do we then insert Tags/keywords for a page?

  2. scribu
    Member
    Posted 4 years ago #

    Pages are normally meant to be displayed one at a time, or in a hierarchical list. Posts grouped by a tag are displayed in a flat list.

    Anyway, just add this code to your theme's functions.php file:

    // Make the metabox appear on the page editing screen
    function tags_for_pages() {
    	register_taxonomy_for_object_type('post_tag', 'page');
    }
    add_action('init', 'tags_for_pages');
    
    // When displaying a tag archive, also show pages
    function tags_archives($wp_query) {
    	if ( $wp_query->get('tag') )
    		$wp_query->set('post_type', 'any');
    }
    add_action('pre_get_posts', 'tags_archives');

    Someone interested in this functionality should make a plugin out of it.

  3. rajesh0228
    Member
    Posted 4 years ago #

    Scribu, thanks for attempting to help but I am getting this error after inserting your code -

    Fatal error: Call to undefined function register_taxonomy_for_object_type() in .......wp-content/themes/suffusion/functions.php on line 1407

  4. Mark / t31os
    Moderator
    Posted 4 years ago #

    register_taxonomy_for_object_type is as of WordPress 3.0, unfortunately won't work for 2.9.2, and most likely an oversight by Scribu.. ;)

    Have you considered updating to 3.0?

  5. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, my site is about to be completed . I am afraid something may go wrong after updation which may set things back by several days.I do not want to go through this possible nightmare.

    t31os_, are you sure it's absolutely safe to UPGRADE - from 2.9.2 to 3?

  6. Mark / t31os
    Moderator
    Posted 4 years ago #

    I wouldn't want to make any guarantees, my suggestion would be to backup, try an upgrade and restore the installation back if things don't quite work out.

    The choice, as they say, is yours.. :)

  7. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, can it be done sans the Upgradation?
    Is there any other alternative?

    Ok...I've got an idea: Can I insert the tags/keywords in the Slug text-box of a Page?

  8. Mark / t31os
    Moderator
    Posted 4 years ago #

    t31os_, can it be done sans the Upgradation?

    Alternative : Modify the file that registers the default post types and add post_tag in as a supported taxonomy (untested but should work in theory).

    Ok...I've got an idea: Can I insert the tags/keywords in the Slug text-box of a Page?

    The slug is used to generate the permalink, so no you wouldn't use it for tags.

  9. rajesh0228
    Member
    Posted 4 years ago #

    Alternative : Modify the file that registers the default post types and add post_tag in as a supported taxonomy (untested but should work in theory).

    t31os_, sorry but I do not know the file you're referring to. And btw, are you sure it's "post_tag" - & not "page_tag"?

    t31os_, can you tell me why in the world is the Tag option non-existent for a Page. After all it's there in Post for SEO!
    Pages too deserve to be SEO-compatible. Don't you think so?

  10. Mark / t31os
    Moderator
    Posted 4 years ago #

    Pages are intended to be static, they are an emulation of a regular static page, which does not have a grouping nature like posts, which would generally displayed in a list.

    Tags are a way to group similar types of content, this isn't really applicable to pages because they have a differing intended function, in that they are displayed as singular static entities, unlike posts which are typically displayed as archives, where you see a list of posts (not a singular item - although they have singular views).

    And no, the name is post_tag, it won't change just because you're registering the taxonomy to another post type.

    RE: Which file, gimme 2 mins, i'll go dig it up for you, will edit this post once i know.

    EDIT: The file that registers the default post types is wp-includes/post.php.

  11. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, sorry I should've told you earlier but I am not an expert on PHP. The post.php is open before me right now. Mind telling me the exact code that I need to insert - & where?

  12. Mark / t31os
    Moderator
    Posted 4 years ago #

    My mistake, things were quite different pre-3.0, you might need to do it on the taxonomy registration which is located in wp-includes/taxonomy.php.

    Like i said, it was untested and just a theory.

    In theory, assuming at this point it's supported.

    Line 19:

    register_taxonomy( 'post_tag', 'post', array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'), 'query_var' => false, 'rewrite' => false) ) ;

    Add page as a post type to register the taxonomy for (again this is untested).

    register_taxonomy( 'post_tag', array('post','page'), array('hierarchical' => false, 'update_count_callback' => '_update_post_term_count', 'label' => __('Post Tags'), 'query_var' => false, 'rewrite' => false) ) ;

    If that doesn't work i'm outta ideas, aside from updating to get 3.0 functionality.

  13. rajesh0228
    Member
    Posted 4 years ago #

    Ok t31os_, I've done precisely what you want me to.
    Will this result in a Tag text-box in the Quick Edit form of the Page? If yes, none exists?

  14. Mark / t31os
    Moderator
    Posted 4 years ago #

    I don't know honestly, have not tested, i also don't tend to use Quick Edit myself.

    Test the main page editor page (the full blown editor) and see if the tag box appears, if it's there, then presumably it should work in all the same ways as it does for posts (though i can't guarantee that will happen or work).

    Try it and see.. :)

  15. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, sorry the Tag text-box also doesn't appear in the full-blown editor. Btw, is there any plug-in for this?

  16. Mark / t31os
    Moderator
    Posted 4 years ago #

    Not that i know of (i only use Akismet, all other plugins i use are self-written).

    You could avoid the whole issue by upgrading, 3.0 has much better support for custom post types and adding taxonomy support to post types, be it custom or built-in post types.

    What is it that you've modified that causes concern about upgrading?

  17. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, I appreciate your help so far.

    What is it that you've modified that causes concern about upgrading?

    I've installed plug-ins (CJ Coming Soon,Collapsible Elements,Comment Notifier,Fast and Secure Contact Form,Wibiya Toolbar,WP-Cirrus,WP Clickcha,CKEditor for WordPress) & a theme (Suffusion). That's the concern - if that's what it's supposed to be!

    Btw, t31os_, let me inform you that my home page contains links to all the Pages I've created. And each of these Pages have their related navigation/menu bar at the top.

    You know what...my reason for creating this thread is because I am interested in the SEO of my Pages. And since the Tag entry is absent for Pages I am worried. But I must also inform you that I've properly named the permalinks (contains the relevant words) of these Pages. Just in case it may help in the SEO of my Pages.

  18. Mark / t31os
    Moderator
    Posted 4 years ago #

    Why not install 3.0 in a test environment(sub-folder/sub-domain, or local install) and run the plugins on the test install to see if any problems occur, same could be said for the theme, that way you don't have to mess with the current installation.

    SEO wise, i don't think it will help much (i don't know in total honestly, don't take much interest in SEO), but if you have duplicate tags across pages and posts it could count as duplicate content, which is a negative in terms of SEO i believe.

    I tend to find the provided permalink structures and archive setup of WordPress ranks perfectly fine in search engines, you could take one of the many WordPress.com blogs or the WordPress sites themselves as examples.

  19. rajesh0228
    Member
    Posted 4 years ago #

    t31os_, FYKI I noticed something that I may've forgotten.

    My Suffusion theme offers me the facility to insert the following info for each Page:keywords & description. This exists in the edit page.

    So I found my solution!

    Thanks again t31os_ for taking time out to help me.

  20. Mark / t31os
    Moderator
    Posted 4 years ago #

    You're welcome.. :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags