Skip to:

Conditional Meta Tags per Page Type, and More?

  • Mr. Grim Reaper


    I was wondering, while designing my new theme, could you implement conditional meta tags? Specifically, robots control. I’d like to add noindex and nofollow to log-in pages, registration pages, user profiles, et cetera.

    I wish there was a “Codex” for bbPress…

Viewing 3 replies - 1 through 3 (of 3 total)

  • Mr. Grim Reaper


    Anyone? Simple “if page” stuff. Yet, I don’t know what the variables are. :|



    It’s very easy to do this via a plugin.

    You have to attach to the ‘bb_head’ action.

    In fact if there’s a plugin for WordPress that does it, it would take under a minute to change it for bbPress.

    Here’s a mini-plugin I wrote to do noarchive and nofollow:

    function no_archive() {
    echo "n".'<meta NAME="robots" CONTENT="noarchive,nofollow">'."n";
    } add_action('bb_head', 'no_archive');


    It would just have to be wrapped in an IF statement with a URI check to add it when you want it. To get the current location, either check bb_get_location or steal it’s code and modify as desired.

    Something like this (untested)

    function no_index() {
    if (in_array(bb_get_location(),array("login-page","register-page","profile-page")) {
    echo "n".'<meta NAME="robots" CONTENT="noindex,nofollow">'."n";
    } add_action('bb_head', 'no_archive');

    Mr. Grim Reaper


    Thanks, though I’m a little confused. I put that in as a plugin file (with the plugin info up top) and I got a fatal error when I tried activating it. Sorry, but I’m totally new to bbPres, and WordPress alike.

    Edit: Never mind, I noticed a slight typo (you wrote the wrong function name and forgot a parenthesis) but it works like a charm now. Thanks for that. :]

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