WordPress.org

Ready to get started?Download WordPress

Forums

Relevanssi - A Better Search
Specifying Weight For Individual Pages? (4 posts)

  1. suntower
    Member
    Posted 9 months ago #

    Is there a way to force the weighting of certain specific pages?

    IOW: If I have 5 pages with the key word 'toast', I would like to make sure that post->ID 1002 -always- appears first in the result list.

    How can this be done?

    http://wordpress.org/plugins/relevanssi/

  2. Mikko Saari
    Member
    Plugin Author

    Posted 9 months ago #

    Using relevanssi_hits_filter filter is the best way - the filter has two parameters: the results and the query. If the query is 'toast', you can make sure the post 1002 is first in the results.

  3. suntower
    Member
    Posted 9 months ago #

    Hi Mikko,

    I'm a bit surprised. I thought I'd want to use something like this:

    add_filter('relevanssi_match', 'custom_tag_weights');
    
    // force a given post ID to top
    if($match->doc == 3246)
      $match->weight = $match->weight * 10;

    ...what's the difference? Or rather, why is relevanssi_hits_filter a better solution?

    Thanks,

    ---JC

  4. Mikko Saari
    Member
    Plugin Author

    Posted 9 months ago #

    That is a good way, too, but adjusting the weights is just a suggestion, while relevanssi_hits_filter lets you modify the order exactly. Of course, if you give enough extra weight, the post will come on top, but with relevanssi_hits_filter, you can place it first, period.

Reply

You must log in to post.

About this Plugin

About this Topic