Support » Plugin: Relevanssi - A Better Search » BUG REPORT: “highlight” parameter forces page_for_posts to load at base URL

  • Resolved JacobTheDev

    (@revxx14)


    We’ve discovered an issue affecting multiple sites where when visiting the base URL for a website with the “highlight” parameter specified, the posts page is being loaded instead of the front page.

    To recreate:

    1. Under Settings -> Reading, set “Your homepage displays” to “A static page (select below)”.
    2. Next to “Homepage,” select a static page to serve as the front page
    3. Next to “Posts page,” select a page to serve as the posts page
    4. Install Relevanssi on a WordPress site, and enable highlighting
    5. Search for a phrase that appears on the home page, and click the link (which should contain the ?highlight parameter)
    6. Observer that the posts page gets incorrectly shown instead of the front page

    I’ve confirmed this on two separate sites using the TwentyTwentyTwo theme, so it’s not an issue with our code. I tried looking through the plugin to determine what was happening, but didn’t make any headway, I suspect it’s something to do with the query modification.

    This does not occur with other query strings on the front page, so clearly it’s something to do with this plugin. We discovered this issue when a client using this plugin pointed it out to us, so the sooner this could be fixed, the better.

    Thanks much!

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

    (@msaari)

    This is a known issue: I’m aware that it’s not possible to add the highlight parameter to home page URLs. The thing is, Relevanssi shouldn’t do that in the first place.

    There is indeed a bug in the checking code. In the function relevanssi_add_highlight() in lib/common.php, this line:

    if ( ! relevanssi_is_front_page_id( isset( $link_post->ID ) ?? null ) ) {

    should be

    if ( ! relevanssi_is_front_page_id( $link_post->ID ?? null ) ) {

    I’ll fix this in the next version, but as I just released a new version, the next version will likely come out at some point in June. If you want a quick fix, the updated common.php is on GitHub.

    Thread Starter JacobTheDev

    (@revxx14)

    Alright, I went in and made that change, at least that makes the page accessible from search. My client would really like the front page to be highlightable, is there a technical reason that this can’t be done?

    Plugin Author Mikko Saari

    (@msaari)

    Well, you’ve seen what WordPress does when you try to add the highlight parameter. Unfortunately, I haven’t figured out a way around that so far, and the front page cannot take highlights.

    This is also a fairly low priority issue, as most of the time, front pages aren’t included in the search.

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