Forum Moderators: coopster

Message Too Old, No Replies

Add noindex,follow

Need to add no index follow to archive pages WP

         

cheaperholidays

11:55 am on Jan 10, 2007 (gmt 0)

10+ Year Member



Hello all

I wonder if anyone can help? I need to noindex our archive pages

We use this in the head of our index.php

<?php
if (is_home() && ($paged <= "1")) {
echo "<meta name=\"robots\" content=\"index,follow\"/>\n";
} else {
echo "<meta name=\"robots\" content=\"noindex,follow\"/>\n";
}
?>

Which works very well on page/2/ for eg, however our archive pages start late-deals/2006/12 and these pages need the noindex,follow,

I cannot get the noindex tag to drop in....

Kind regards

Pete

omoutop

12:07 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



The logic of applying your meta this way is correct.

Now instead of seeking $page (which may be tough depending on your site structure), I would suggest to build a flag of some kind and check this flag on top of every page (on some include file perhaps)

Now your code would look like

if ($flag=="Y")
{
// noidex,follow
}
else
{
// index,follow
}

Now this can be tricky (based on the info/data you have for each page), but it's an alternative

cheaperholidays

12:18 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



Hi omoutop

The problem is the archives are fed from our index.php page, and not on say archives .php.

So you get

<title>Cheap holiday deals late and News by .com &raquo; 2006 &raquo; December</title>

So i suppose we would need, some sort of catch all to cover 2005/12/ 2006/12 and so on.

Thanks
Pete

omoutop

12:27 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Is the 2005/12/, 2006/12 part of your url dates (year/month format)?

If so, you can create some flags based on years and months and check these.
Also, did you create your url with mod_rewrire? If so, you may find some clues on the creation pattern there

cheaperholidays

12:55 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



Thanks omoutop for your speedy reply

I may be being a bit thick here, but can you show me an example of what the include should contain, also we still need to keep the noindex in page/2 and so on

As a fall back is there a way we can add the code to our original php

if (is_home() && ($paged <= "1")) and add the 2006 2005 catch all for noindex.

I tried this and got tstring error && ($2006d <= "1")

Kind regards
Pete

eelixduppy

1:05 pm on Jan 10, 2007 (gmt 0)



Just a little side-note here, which may be causing your problem. Variable names [us2.php.net] cannot start with a number. So $2006d is not correct. Maybe you want to make it $d2006 instead?

Secondly you do not need the quotes around the "1" in your conditional since the value you are comparing should contain an integer and not a string.

omoutop

1:56 pm on Jan 10, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Well lets see....

$invalid_years = array("2005","2006");
$invalid_months = array("1","3","5","11");

$year_to_check = 2007;
$month_to_check = 1;

if (in_array($year_to_check, $invalid_year) && in_array($month_to_check, $invalid_month))
{
// noindex
}
else
{
// index
}

Of courc you will have to modify your code to create the invaid arrays

cheaperholidays

7:54 pm on Jan 10, 2007 (gmt 0)

10+ Year Member



Thanks guys for your help, apple-ogies if any of you are females..

I decided that the monthly archives can stay as they are, all the cat pages are blocked with nofollow.

It was driving me nuts, i ma sure google knows what archives are by now

Kind regards

Pete