• Resolved rajesh0228

    (@rajesh0228)


    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?

Viewing 15 replies - 1 through 15 (of 19 total)
  • 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.

    Thread Starter rajesh0228

    (@rajesh0228)

    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

    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?

    Thread Starter rajesh0228

    (@rajesh0228)

    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?

    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.. ??

    Thread Starter rajesh0228

    (@rajesh0228)

    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?

    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.

    Thread Starter rajesh0228

    (@rajesh0228)

    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?

    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.

    Thread Starter rajesh0228

    (@rajesh0228)

    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?

    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.

    Thread Starter rajesh0228

    (@rajesh0228)

    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?

    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.. ??

    Thread Starter rajesh0228

    (@rajesh0228)

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

    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?

Viewing 15 replies - 1 through 15 (of 19 total)
  • The topic ‘Tags for Pages’ is closed to new replies.