Keep spiders out of forum categories?
-
How to do this?
-
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.
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.
So you need to modify the if( … ) statement to look for those properties. What are you having a problem with?
<?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.
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 -->';
}
}
?>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.
bb_head
appears to be a filter.Using latest trunk code, but bb_head works fine in combo with add_action here.
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?
- You must be logged in to reply to this topic.