bbPress

Simple, Fast, Elegant

bbPress support forums » Themes

Conditional Meta Tags per Page Type, and More?

(4 posts)
  • Started 4 months ago by Mr. Grim Reaper
  • Latest reply from Mr. Grim Reaper
  • This topic is resolved
  1. 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...

    Posted 4 months ago #
  2. Anyone? Simple "if page" stuff. Yet, I don't know what the variables are. :|

    Posted 3 months ago #
  3. 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');
    Posted 3 months ago #
  4. 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. :]

    Posted 3 months ago #

RSS feed for this topic

Reply

You must log in to post.

Code is Poetry.