Support » Plugin: Relevanssi - A Better Search » Problem with repositioning listings on site

  • Resolved shmumu

    (@shmumu)


    Hey
    I have a website with apartments for rent (each apartment is called a “listing”) and there is an option to “jump registration” for a fee.
    That is, whoever pays for a bounce, his listing goes up to the top of the list.
    I’m using your great search, and I’m having a problem.
    On the site you can search by categories (days, weekends, holidays, etc.), and you can write the specific city in the search bar.
    That is, the user registers the city, selects a category, and performs a search.
    The problem is that if the user registers the city and performs a search, the listings that are supposed to be popped up, remain in their usual place and do not rise to the top of the list.
    I talked to the programmer, and he debugged the problem and sent me the following email:

    made some research and indeed this plugin breaks the featured listings query. Please try contacting their support regarding this – there’s a regular get_posts query (not the main search query) but it’s still affected by the plugin https://github.com/hivepress/hivepress/blob/master/includes/components/class-attribute .php # L1687 When I remove the supress_filters parameter it starts working (I guess because their plugin filters the query), also if I remove the s parameter (I guess their filter is applied only if some search term is defined).

    You can also check if there’s a plugin setting to apply their search to the main queries only (not regular queries like the featured listings one).

    I would be very happy for your help, I do not understand enough of this to explain more.
    Thanks in advance!

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

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

    (@msaari)

    How exactly is that query breaking? As far as I can tell, that get_posts() query should work with Relevanssi. It doesn’t do anything weird: it just sets some query parameters and asks for post IDs in random order. Relevanssi should be able to handle that.

    Anyway, you can try this:

    add_filter( 'relevanssi_search_ok', function( $ok, $query ) {
      if ( 'hp_featured' === $query->get( 'meta_key' ) ) {
        $ok = false;
      }
      return $ok;
    }, 10, 2 );

    Adding this to your theme functions.php or in a code snippet should disable Relevanssi in this query.

    Thread Starter shmumu

    (@shmumu)

    First thing – thank you so much for the help!

    I added the code snippet to the site, and the issue is still unresolved.
    Is there perhaps something else that can be done? I also changed the settings of the plugin and checked every time after the change, and it did not help.
    I’m not just asking, the monetization of my site is based on the possibility of bouncing a listing.

    Thanks in advance!!

    Plugin Author Mikko Saari

    (@msaari)

    Try adding this, too:

    add_filter( 'relevanssi_prevent_default_request', function( $prevent, $query ) {
      if ( 'hp_featured' === $query->get( 'meta_key' ) ) {
        $prevent = false;
      }
      return $prevent;
    }, 10, 2 );

    Does that help? If it doesn’t help, try this instead of the previous functions:

    add_filter( 'relevanssi_search_ok', '__return_false' );
    add_filter( 'relevanssi_prevent_default_request', '__return_false' );

    Does that work?

    Thread Starter shmumu

    (@shmumu)

    Thank you! Helped me a lot!
    problem solved.

    Plugin Author Mikko Saari

    (@msaari)

    Was it the first snippet that fixed the problem? Or the second? If it was the second, do note that that also disables Relevanssi completely =D

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.