WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Limit No. Of Search Pages Created (12 posts)

  1. Perryb2006
    Member
    Posted 2 years ago #

    Hi,
    I am using this plugin for a long time now and really love it :)

    Being a novice at SEO, I barely noticed the stats in Google Webmaster tools. However, recently I discovered that it was reflecting a huge number of duplicate title tags and majority of url's were the search pages created viz. "/search/<search term>/page/2", etc.

    Is there a way to restrict the number of results shown by Relevanssi so that such a huge number of sub pages aren't created and thus lesser duplicate title tags?

    Thanks for such an awesome plugin :)

    http://wordpress.org/extend/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    I suppose so, though the best way to handle this in my opinion is to set robots meta noindex on your search results pages (or block them in robots.txt).

  3. Perryb2006
    Member
    Posted 2 years ago #

    Isn't it possible to index the first page of search and noindex, follow the sub pages?

    Thanks for prompt reply :)

  4. Perryb2006
    Member
    Posted 2 years ago #

    Will this work:
    DISALLOW: /search/*/page
    to block all the pages except the first search page?

  5. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    No, that won't work in robots.txt, it doesn't support wild cards like that.

    Google recommends setting all search results pages to noindex, so I'd go with that, but if you want to noindex everything but the first page, you should do it with meta tags you set in WordPress - setting noindex on everything but the first page is not complicated that way.

  6. Perryb2006
    Member
    Posted 2 years ago #

    Could you please help me out in this regard? I am not that great with Robots.txt handling.

    Thanks :)

  7. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    In your header template, add

    <?php
    global $wp_query;
    if (is_search() && $wp_query->query_vars['page'] > 1)
    echo "<meta name='robots' content='noindex' />";
    ?>

    That should do the trick, I think.

  8. Perryb2006
    Member
    Posted 2 years ago #

    Thanks for the code, I'll implement it and see if it takes care of the errors.
    Also, is there a way to restrict number or search results shown in Relenvassi? As of now it shows 10 results per page and maximum of 500 but if I could change this to 10 results per page with maximum of 10 i.e only show 10 results of the search performed. This will not create sub pages and hence no duplication in search engine.

    I tried to implement this by editing the plugin file and changed the following code

    add_filter('relevanssi_query_filter', 'relevanssi_limit_filter');
    function relevanssi_limit_filter($query) {
    	if (get_option('relevanssi_throttle', 'on') == 'on') {
    		return $query . " ORDER BY tf DESC LIMIT 10";

    ~Changed 500 to 10~
    But this didn't work :/
    IMO this will be better option.

  9. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    That doesn't work, as it's ten hits per search term.

    Use the relevanssi_hits_filter and trim the $hits[0] array to desired length.

  10. Perryb2006
    Member
    Posted 2 years ago #

    $filter_data = array($hits, $q);
    	$hits_filters_applied = apply_filters('relevanssi_hits_filter', $filter_data);
    	$hits = $hits_filters_applied[10];

    Did what you said. Changes the $hits_filters_applied[0] array to 10 but upon doing so, the search page for all the terms yielded "No Search Results".

  11. Perryb2006
    Member
    Posted 2 years ago #

    Tried the php code as well, didn't work. Got the following error:
    PHP Parse error: syntax error, unexpected T_STRING, expecting ',' or ';' in <directory url>

  12. Mikko Saari
    Member
    Plugin Author

    Posted 2 years ago #

    Try this

    add_filter('relevanssi_hits_filter', 'cuttoten');
    function cuttoten($hits) {
    $ten = array_slice($hits, 0, 10);
    return array($ten);
    }

    That's how you take the ten first hits from the $hits array.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags