• Resolved pstidsen

    (@pstidsen)


    Hi there,

    My theme offer a custom search feature. I have digged into it and I can see that the search is made by this get_posts-call:

    
    $products = get_posts([			
    			'post_type' => 'product',
    			'orderby' => 'title',
        		'order' => 'ASC',
        		'numberposts' => 200,
        		's' => $query
    		]);
    

    I have set up some synonyms in the Relevanssi plugin settings but it does not seem to work. Are your plugin able to manipulate with that $query variable so the synonyms are working? Or do I have to change something in order to get the synonyms to work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Change that to

    $args = array(
        'post_type' => 'product',
        'orderby' => 'title',
        'order' => 'ASC',
        'numberposts' => 200,
        's' => $query,
    );
    $product_query = new WP_Query();
    $product_query->parse_query( $args );
    relevanssi_do_query( $product_query );
    $products = $product_query->posts;
    Thread Starter pstidsen

    (@pstidsen)

    Awesome! Thanks ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Search keyword in get_posts’ is closed to new replies.