• Resolved funkopopwave

    (@funkopopwave)


    Hi, i implementing the plugin in my wordpress but i found a little problem. When i make a search the result show my blog posts (no items in the ads database yet) is there a way that the search will be only in the ad database? or this will be solved when will be items in the ad database?. I added the snipped to search only in categories but with the same result

    thanks in advance..

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter funkopopwave

    (@funkopopwave)

    my fault a code in my php function is the cause of this behavior

    Thanks

    Plugin Author Greg Winiarski

    (@gwin)

    Hi,
    the search from [adverts_list] should search inside Adverts by default, if it includes other post types then most likely there is some other plugin modifying the search results, you can try preventing it by adding the code below in your theme functions.php file

    
    add_filter( "adverts_list_query", function( $args ) {
      $args["suppress_filters"] = true;
      return $args;
    } );
    
    Thread Starter funkopopwave

    (@funkopopwave)

    yes, my theme order the results by name by default and i added a code to change this and order by date with this

    
    function my_search_query( $query ) {
    	// not an admin page and is the main query
    	if ( !is_admin() && $query->is_main_query() ) {
    		if ( is_search() ) {
    			$query->set( 'orderby', 'date' );
    		}
    	}
    }
    add_action( 'pre_get_posts', 'my_search_query' );

    and this for exclude pages from the result

    
    //Exclude pages from WordPress Search
    if (!is_admin()) {
    function wpb_search_filter($query) {
    if ($query->is_search) {
    $query->set('post_type', 'post');
    }
    return $query;
    }
    add_filter('pre_get_posts','wpb_search_filter');
    }
    • This reply was modified 5 years, 6 months ago by funkopopwave.
    • This reply was modified 5 years, 6 months ago by funkopopwave.
    Plugin Author Greg Winiarski

    (@gwin)

    Ok, then adding the code i pasted as well should help with the [adverts_list] search.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Search form search in blog post’ is closed to new replies.