• Resolved eclec

    (@eclectic77)


    Hello, I’m using Relevanssi for search with headless WordPress. I need to display weight score / pertinence score in my results page, How I gan get it ?

    Thanks.

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

    (@msaari)

    If you have Relevanssi return post objects, Relevanssi adds the relevance score in $post->relevance_score for each post. You can get it there.

    If you have Relevanssi return just post IDs, then you get only the post ID, and can’t get the relevance score.

    Thread Starter eclec

    (@eclectic77)

    I’m in WP_query with search parameter dans other custom search parameter, so I can’t get it in this query ?

    Thread Starter eclec

    (@eclectic77)

    found solution with

    
    $meta_query = new WP_Query();
    $meta_query->parse_query( $args );
        relevanssi_do_query( $meta_query );

    Thanks a lot !

    • This reply was modified 3 years, 3 months ago by eclec.
    Plugin Author Mikko Saari

    (@msaari)

    If your WP_Query returns you post objects, those post objects will have the relevance score in the relevance_score attribute.

    Also, these days I recommend doing this instead:

    $args['relevanssi'] = true;
    $meta_query = new WP_Query( $args);

    This is better, as this code won’t break if Relevanssi is inactive.

    Thread Starter eclec

    (@eclectic77)

    Thanks !

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to display weight / pertinence score’ is closed to new replies.