Strict Standards: Redefining already defined constructor for class bbdb in /home/themes/public_html/forums/bb-includes/db-mysql.php on line 12

Strict Standards: Declaration of BB_Walker_Blank::start_lvl() should be compatible with BB_Walker::start_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_lvl() should be compatible with BB_Walker::end_lvl($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::start_el() should be compatible with BB_Walker::start_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127

Strict Standards: Declaration of BB_Walker_Blank::end_el() should be compatible with BB_Walker::end_el($output) in /home/themes/public_html/forums/bb-includes/classes.php on line 1127
Help with thematic_create_robots custom filter please. :) « ThemeShaper Forums

ThemeShaper Forums » Thematic

[closed]

Help with thematic_create_robots custom filter please. :)

(8 posts)
  • Started 5 years ago by bigtoe
  • Latest reply from helgatheviking
  • This topic is not resolved
  1. bigtoe
    Member

    Hi there.

    I'm trying to modify a "thematic_create_robots" filter and it's not going well.

    Any help would be greatly appreciated.

    I would like to make http://example.com/page/2 and all those paged URLs have a "noindex,follow" robots meta tag, basically, the entire /page/ dir.

    I tried messing around with the ((is_home() && ($paged < 2 )) bits, and it's not working, probably because I'm not very good with php.

    Do I need to create another elseif statement, and how?

    I don't have any SEO plugins installed, and would like to do this with the filter.

    Here's what I have in functions.php for your reference. Thanks in advance.

    function childtheme_create_robots() {
     if((is_home() && ($paged < 2 )) || is_front_page() || is_single() || is_attachment()) {
     $content .= "<meta name=\"robots\" content=\"index,follow\" />";
     } elseif (is_search()) {
     $content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />";
     }
    /*
    elseif (is_page('about-me') {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     }
    */
    else {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     }
        return $content;
    }
    add_filter('thematic_create_robots', 'childtheme_create_robots');

    With the above, I get "index,follow" for everything in /paged/

    Posted 5 years ago #

  2. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512
    Chris

    Moderator

    Hi,

    add global $paged; as first line in your function.

    Chris

    Posted 5 years ago #
  3. bigtoe
    Member

    Hi Chris.

    Thanks for the reply. I did the the following, and I'm still showing "index,follow" for everything in /paged/ from the front page unfortunately.

    No idea what I'm doing wrong. Here's what I have.

    function childtheme_create_robots() {
    global $paged;
     if((is_home() && ($paged < 2 )) || is_front_page() || is_single() || is_attachment()) {
     $content .= "<meta name=\"robots\" content=\"index,follow\" />";
     } elseif (is_search()) {
     $content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />";
     } 
    
    else {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     }
        return $content;
    }
    add_filter('thematic_create_robots', 'childtheme_create_robots');

    Hopefully it's a simple fix. Thanks.

    Posted 5 years ago #
  4. bigtoe
    Member

    Still can't figure this out. Anybody got a minute? Been cracking my head for hours.

    Do I need to modify this ((is_home() && ($paged < 2 ))or is there some other statement I can add to the filter?

    Something like

    elseif "/page/" {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     }

    I tried reversing the < sign, and a bunch of other things that got me syntax errors, but it ended up putting noindex on the front page. Yikes.

    Wish I were decent at php, but it makes my brain hurt.

    Posted 5 years ago #
  5. bigtoe
    Member

    Please sir, may I have some help.

    So I gave this another shot, but apparently I suck.

    Here's what I got, and I'm still getting "index,follow" on "example.com/page/3" etc URLs. I need "noindex,follow".

    function childtheme_create_robots() {
    
     if(is_front_page() || is_single() || is_attachment()) {
     $content .= "<meta name=\"robots\" content=\"index,follow\" />";
     } elseif (is_search()) {
     $content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />";
     } 
    
    elseif (is_paged()) {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     } 
    
    else {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />";
     }
        return $content;
    }
    add_filter('thematic_create_robots', 'childtheme_create_robots');

    Where did I mess up?

    Posted 5 years ago #
  6. bigtoe
    Member

    Figured it out.

    Looks like is_paged() doesn't work standing on its own and needs another conditional with it. And I'm just guessing.

    Thanks for playing wheel of fortune.

    Pasting my filter below so anybody else who wants to copy/use/modify/analyze/obfuscate/clean up/comment/study/port to assembly/delete/discuss it can do so.

    function childtheme_create_robots() {
     if((is_home() && !is_paged()) || (is_front_page() && !is_paged()) || is_single() || is_attachment()) {
     $content .= "<meta name=\"robots\" content=\"index,follow\" />\n\n";
     }
    elseif (is_search()) {
     $content .= "<meta name=\"robots\" content=\"noindex,nofollow\" />\n\n";
     }
    else {
     $content .= "<meta name=\"robots\" content=\"noindex,follow\" />\n\n";
     }
        return $content;
    }
    add_filter('thematic_create_robots', 'childtheme_create_robots');
    Posted 5 years ago #
  7. Thompson
    Member

    Update for anyone who stumbles across this as I did when searching. The code above is outdated, but I figured out the current way to modify meta robots:

    // Add noindex to terms/privacy/contact pages
    function my_robots() {
    if (is_page(array(45,142,56))) { //terms,privacy,contact
    echo '<meta name="robots" content="noindex,follow" />';
    }
    else {
    echo '<meta name="robots" content="index,follow" />';
    }
    }
    add_filter('thematic_show_robots', 'my_robots');

    Posted 4 years ago #

  8. Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512


    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 440

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 510

    Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/themes/public_html/forums/bb-includes/kses.php on line 512
    helgatheviking

    Moderator

    seems weird to me. you don't normally echo things out when you are filtering

    Posted 4 years ago #

RSS feed for this topic

Topic Closed

This topic has been closed to new replies.


Strict Standards: call_user_func_array() expects parameter 1 to be a valid callback, non-static method GA_Filter::spool_analytics() should not be called statically in /home/themes/public_html/forums/bb-includes/wp-functions.php on line 586

Strict Standards: Non-static method GA_Filter::spool_this() should not be called statically in /home/themes/public_html/forums/my-plugins/googleanalytics.php on line 183