• Resolved faiqhussain

    (@faiqhussain)


    Hello,
    I have the pro version and I was wondering how would I go about retrieving links with anchors such as “www.site.com/#anchor1”.
    Thank you,

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

    (@msaari)

    What exactly is the use case here? What do you mean with the question? Relevanssi can’t return links to anchors on the pages, because Relevanssi doesn’t know anything about the post structure, Relevanssi just sees the post content, and that only in individual words.

    Thread Starter faiqhussain

    (@faiqhussain)

    Thank you for the quick response Mikko.
    The situation I am in is that I have a long page and the content that needs to be searched is in the middle of the page.
    If someone were to navigate to the link : https://www.site.com/#anchor I have a script that will scroll down to the page to the reference of ‘anchor’.
    I believe a better way of asking is, ‘Can we have custom links populate on keyword searches?’
    Thank you

    Plugin Author Mikko Saari

    (@msaari)

    It’s up to you and your theme what the search results page shows. However, figuring out which anchor to add to the link may be somewhat complicated. Relevanssi can’t really help you with that because like I said, Relevanssi doesn’t really understand the page structure.

    You can have Relevanssi add an anchor to the search results page links that contains the search term, which you can then use to scroll the page to where that term appears. See this: https://www.relevanssi.com/knowledge-base/scroll-result-page-search-term/

    Thread Starter faiqhussain

    (@faiqhussain)

    Ah so no custom linking then? Thank you ??

    Plugin Author Mikko Saari

    (@msaari)

    You can have the search results pages link to wherever you want – it’s totally under your control, but that also means you have to build it yourself. If you’re interested in customizing, you can customize the linking as much as you want. Relevanssi doesn’t really care.

    Relevanssi doesn’t even generate the links in the first place, they come from WordPress permalink structure. So that’s where you need to customize, not at Relevanssi.

    Thread Starter faiqhussain

    (@faiqhussain)

    I found something I can work with on your forum. Great forum by the way. https://www.relevanssi.com/knowledge-base/scroll-result-page-search-term/
    I will try to implement this. Hopefully I can get the ‘highlighted search word’ scrolled into view.

    Thread Starter faiqhussain

    (@faiqhussain)

    I am close to finding a solution and I must as how does Relevansi adds the strong tag to the content? is that a core function of WordPress? Thank you.

    Plugin Author Mikko Saari

    (@msaari)

    No, it’s not a core function, it’s custom-built. All that is in the file /lib/excerpts-highlights.php, start from relevanssi_do_excerpt().

    Thread Starter faiqhussain

    (@faiqhussain)

    Hello Mikko,
    I found a solution. In my search results page I add this to the link (cleaned-up from my theme) :
    <a href="<?php the_permalink(); ?>#<?php _e($s);?>" ); ?>">Title</a>
    sloppy, I know but it allowed me to add the keyword to the url and then I grabbed the keyword on the post page using a JS and scrolled to the first keyword.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘custom Linking to Anchors’ is closed to new replies.