• Resolved mluce

    (@mluce)


    I installed the Relevanssi plugin and it works fine except that the search does not seem to find all the pages when the searched term is a link anchor. For example, when I type “document”, it only finds me one page with the word “document” in it. There are some other pages where the word “document” appears in a link anchor and those are not listed in the search results. I would think that the Relevanssi plugin does not look through link anchors except that the only page it finds also has the search term in a link anchor. Does it have to do with external or internal links?
    Thanks in advance for any reply.

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

    (@msaari)

    Relevanssi does index the link anchors. In fact, Relevanssi doesn’t even know what is a link anchor or not, because Relevanssi removes all HTML tags in the indexing process. The link anchors are like any other text.

    If you look at the posts that aren’t found with the Relevanssi debugger (Settings > Relevanssi > Debugging), does the word “document” appear there? Are the links in plain post content, or what’s the context?

    Thread Starter mluce

    (@mluce)

    Hello,
    Thank you for your reply. When I try debugging, the word “document” does not appear. The links are not in plain post content, they are in the page but in a separate div, is it why Relevanssi jumps over them when looking at the post content?

    Plugin Author Mikko Saari

    (@msaari)

    Could you perhaps show me how the page source code looks like in the wp_posts database table? That would help me assess the situation, otherwise, I can’t really say anything useful. A separate div shouldn’t matter if the link is still in the post_content field, as like I said, Relevanssi wipes off all the HTML tags from the post content.

    Thread Starter mluce

    (@mluce)

    Below is how it appears in the database. Maybe the problem comes from the fact that the term is inside a button module :

    [et_pb_button button_url="https://hubs.ly/H0-9pQq0" url_new_window="on" button_text="Our document" _builder_version="4.9.7" _module_preset="default"][/et_pb_button]

    Plugin Author Mikko Saari

    (@msaari)

    Yes! Relevanssi does not read shortcode attributes by default, they are discarded.

    See “Indexing blurbs” here for a method of reading attributes: https://www.relevanssi.com/knowledge-base/divi-page-builder-and-cleaner-excerpts/

    In your case, it would be something like:

    add_filter( 'relevanssi_pre_excerpt_content', 'rlv_shortcode_attribute', 8 );
    add_filter( 'relevanssi_post_content', 'rlv_shortcode_attribute', 8 );
    
    function rlv_shortcode_attribute( $content ) {
    	return preg_replace( '/\[et_pb_button.*?button_text="(.*?)".*?\]/im', '\1 ', $content );
    }
    Thread Starter mluce

    (@mluce)

    Thanks, it worked!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Issue with terms in link anchors’ is closed to new replies.