To insert code use <code>...</code>.
Remove porfolio from wordpress search engine
  • How can I acomplish this ?

    I have a portfolio with 50 items, each one of them is just a link to a full post.

    Example:

    You see portfolio with sortble option, so you see 50 images with a tiltle.
    When you click an image, you go directly to a normal post that has the complete info of that portfolio item.

    This is the problem.

    If you search for one of those items, you get 2 results, 1 empty portfolio with just one image and 1 full and complete post.

    Of course the post is the one I want people to see.

    How can I fix this problem ?

    Thanks.
  • 17 Comments sorted by
  • Interesting, I would like to know this as well.
  • Can anyone help here ?
  • Still looking into this, its a big problem I need to fix.

    Thanks.
  • Anyone that knows a solution ?
  • Hi,
    You can add the content below to the bottom of striking/functions.php file.


    add_action('wp_head', 'theme_no_follow_portfolio');
    function theme_add_viewport_meta() {
    if(is_singular('portfolio')){
    echo "\n" . '<meta name="robots" content="noindex,nofollow">' . "\n";
    }
    }


    Regards,
    KaptinLin
  • Hi.

    If I add it to my child theme, it does not work. (I get all the duplicate results)
    If I add it to main and child I get a blank page.
    If I add it to main theme, it does not work. (I get all the duplicate results)

    So that its not working.

    Thanks.
  • Hi,

    It need time to take affect.

    The code just tell google engine not to index the portfolio item page.

    If the engine already indexed it, you may learn from http://support.google.com/webmasters/bin/answer.py?hl=en&answer=1663419 to remove it.

    Regards,
    KaptinLin
  • But what does google have to do with my site internal search ?

    If someones go to my site and search, the result is duplicated, thats the problem. I don't get the Google thing.

    Thanks.
  • Hi polle,

    Everybody here was thinking about search engines (Google, Yahoo, etc). What you want is an entirely different thing.

    Cris
  • Yes, thats why I explained it. Not sure, but for me its very clear in the explanation, but for everybody out there willing to help, I am talking of wordpress search engine, my sites search engine, the internal search engine of my site.

    That one has duplicates and those are the ones I need to fix.

    Thanks.
  • Anyone that can help ?
  • Is this possible ?
  • I will update this with a problem.

    I replaced my search with google custom search and then add the code to functions that Kaptinlin suggested, that way everything will work.

    Wrong.

    When I add that code to my functions, no mobile device can see the site, a blank page is displayed.

    Here is the error log:


    PHP Fatal error: Cannot redeclare theme_add_viewport_meta() (previously declared in /var/www/vhosts/site.com/httpdocs/wp-content/themes/striking-child/functions.php:26) in /var/www/vhosts/site.com/httpdocs/wp-content/themes/striking/framework/functions/head.php on line 220


    So the solution is not working.

    Whats the correct code I can use to make it work ?
  • I had a similar problem. I wanted to exclude all pages from the search results (leaving only posts) and it can be done with an extra bit of code placed in functions.php:

    function mySearchFilter($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }

    add_filter('pre_get_posts','mySearchFilter');


    You can check Relevanssi - A Better Search (http://wordpress.org/extend/plugins/relevanssi/). It's a replace for the standard search engine.
  • Hi michal.

    Can you explain your code ?

    That works for search engines or for internal search ?
    It needs that plugin ?
    It exludes everything but posts ?
    Etc…

    I want to explude portfolio items and notheing else.

    The code Kaptinlin shared looks fine, the problem is that mobile devices see blank pages.

    So I need to just exclude portfolio and thats it.

    My solution is this: Use google custom search and explude portfolio from sitemaps.

    Of course I would like to know the correct solution of Kaptinlin's code.
  • The code will exclude all pages (and portfolio items) and it works without any plugin. All you need to do is to put it in your functions.php.

    You can check http://www.wprecipes.com/how-to-exclude-posts-or-pages-from-search-results
  • Hi there,

    A new option for this will be added to striking->advanced options page in the next release of striking.

    Regards,
    KaptinLin
    1.png
    460 x 233 - 9K
This discussion has been closed.
All Discussions