Skip to:
Content
Pages
Categories
Search
Top
Bottom

Keep spiders out of forum categories?

Viewing 9 replies - 1 through 9 (of 9 total)
  • @fel64

    Member

    What forum categories?

    You want a plugin like this:

    <?php
    /*
    Plugin Name: noindex stuff
    */

    add_action('bb_head', 'my_add_noindex_tag');
    function my_add_noindex_tag() {
    if( is_forum_category() )
    echo '<meta name="robots" content="noindex" />';
    }
    ?>

    That’s off the top of my head, so it may not work without some modification, but that’s what I think the structure needs to be. You’ll need a different conditional tag than is_forum_category(), probably is_forum() if you just wanted to not index forum pages.

    @intellivision

    Participant

    Thanks Fel. I should have added more text:

    I’d like to keep spiders out of forum category 3, but not forum category 4 or 5.

    Specifically I’d like that meta tag to be written to forum category 3 page that lists the threads, and all threads that are in forum category 3.

    @fel64

    Member

    So you need to modify the if( … ) statement to look for those properties. What are you having a problem with?

    @intellivision

    Participant
    <?php
    /*
    Plugin Name: noindex stuff
    */

    add_action('bb_head', 'my_add_noindex_tag');
    function my_add_noindex_tag() {
    if( is_forum(3) ) {
    echo '<meta name="robots" content="noindex" />';
    }
    else {
    echo '<!-- please do index -->';
    }
    }
    ?>

    I modified it a bit to see both conditions… but neither are showing up in my source. Any thoughts?

    I did see it in the plugins control panel, and activate it.

    @simon99

    Member

    is_forum() doesn’t take any arguments, so I believe you’d have to use the global var $forum, like so:

    <?php
    /*
    Plugin Name: noindex stuff
    */

    add_action('bb_head', 'my_add_noindex_tag');
    function my_add_noindex_tag() {
    global $forum;
    if($forum->forum_id == 3) {
    echo '<meta name="robots" content="noindex" />';
    }
    else {
    echo '<!-- please do index -->';
    }
    }
    ?>

    @intellivision

    Participant

    Hmmm still not working. Something’s strange because even this doesn’t show:

    <?php
    /*
    Plugin Name: test stuff
    */

    add_action('bb_head', 'my_add_test_tag');
    function my_add_test_tag() {
    echo '<!-- testing here -->';
    }
    ?>

    I’ve tried activating/deactivating these plugins, and I’ve tried 2 browsers to ensure it’s not cache I’m seeing. Grr.

    @fel64

    Member

    bb_head appears to be a filter.

    @simon99

    Member

    Using latest trunk code, but bb_head works fine in combo with add_action here.

    @finalwebsites

    Participant

    Hi just tried this code but therer is “is_forum_category()” function in my install (ver 0.83).

    Is this a new one for the next version?

Viewing 9 replies - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.
Skip to toolbar