Support » Fixing WordPress » To modify search widget results

  • Hi!

    I’ve been trying to look for a solution on how to change the results of my search bar, it directs in pages where the info is incomplete. it’s like an excerpt of a certain page. Mostly the users are trying to search a product that’s included in my portfolio list.

    Any inputs will be appreciated. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • If you want to restrict the result of search only portfolio list please add the following piece of code in default theme functions.php

    function filter_search($query) {
        if ($query->is_search) {
    	$query->set('post_type', array('name-of-custom-post-type'));
        return $query;
    add_filter('pre_get_posts', 'filter_search');

    You can also add more values in array() like page ,post, and more custom post name to show restrict search result only to that.

    Hello! Sorry for the late reply.

    Thank you for your response. Unfortunately, I can’t seem to figure out the name of the custom post type of my portfolio plugin – Nimble Portfolio. Where I could I possibly find it? I’ve tried putting each of the names of my portfolio but it still won’t work.

    Thanks a lot!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘To modify search widget results’ is closed to new replies.