• Resolved thinkwired

    (@thinkwired)


    I am using the_excerpt in my search results and I can see that relevanssi is bolding the search terms properly but, for some reason, there is no “read more” link displayed. it seems as though a custom function to display the read more link is overwritten by the relevanssi plugin? Or am I missing something?

    How can I add the “read more” link without losing the search term bolding functionality of relevanssi?

    I search google and your site to no avail. I really tried.

    Thank you in advance!

    https://www.ads-software.com/plugins/relevanssi/

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

    (@msaari)

    That is up to your search results template. You couldn’t find anything on Relevanssi documentation, because this falls under the responsibility of your theme, not Relevanssi.

    Thread Starter thinkwired

    (@thinkwired)

    If you want to edit the excerpt to include the read more link, WordPress says to include this function;

    function new_excerpt_more( $more ) {
    	return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>';
    }
    add_filter( 'excerpt_more', 'new_excerpt_more' );

    This doesn’t seem to work on the relevanssi search results. I’m guessing that is because relenassi is modifying the excerpt after or using its own custom excerpt.

    I cant add the “read more” in the template because if I did, it would be added outside/after the excerpt on a new line.

    Plugin Author Mikko Saari

    (@msaari)

    That’s for the WP default excerpt. With Relevanssi, you’re not using the WP default excerpt, so that doesn’t work. You need to add it on the search results template, if you want it. If you want it appear after the excerpt, I’m sure that can be done with CSS styles.

    Thread Starter thinkwired

    (@thinkwired)

    The excerpt automatically creates paragraph elements around the excerpt so, there is no way to move the “read more” link inside of of those P elements with CSS.

    If the results are not using the default WP excerpt, then what is it using? Couldn’t we replace ‘excerpt_more’ (in the following code) with whatever relevanssi is using to display the custom excerpt?

    function new_excerpt_more( $more ) {
    	return ' <a class="read-more" href="'. get_permalink( get_the_ID() ) . '">' . __('Read More', 'your-text-domain') . '</a>';
    }
    add_filter( 'excerpt_more', 'new_excerpt_more' );

    A better solution might be to allow users to custom edit the relevanssi excerpt output like WordPress does. When it comes to displaying only an excerpt, having a “read more” link does make a lot of sense. My 2 cents.

    Plugin Author Mikko Saari

    (@msaari)

    There’s no Relevanssi filter to adjust the read more. Relevanssi excerpts don’t include one. If you want one, you can add it on the search results template; I think it’s better that way anyway, as it gives you more freedom to place the link wherever you want, I find the forced links quite annoying actually.

    So, I’m sorry, but that’s simply how Relevanssi works.

    Thread Starter thinkwired

    (@thinkwired)

    I think it’s better that way anyway, as it gives you more freedom to place the link wherever you want

    But, you dont have the freedom to place the link inside of the excerpt P element. So, you can place it anywhere on the page EXCEPT inside the excerpt itself, which is where it makes the most sense (this is why wordpress gives the option to do it).

    I find the forced links quite annoying actually.

    They are not forced — it is an option that wordpress gives you.

    I understand that this is your baby and repsect your decision, I just want to make sure I clarify that you cannot place the read more link wherever you want inside of the search results template.

    Plugin Author Mikko Saari

    (@msaari)

    You don’t have to print out the excerpt with the_excerpt(). You can also do this:

    <p><?php echo $post->post_excerpt; ?> <a href="<?php the_permalink(); ?>">Read more</a></p>

    if you want the link inside the P tag. That gives you limitless flexibility on where to put the link.

    Thread Starter thinkwired

    (@thinkwired)

    You win! Thank you.

    I was fixated on the_excerpt and totally forgot I could call it manually. THANK YOU.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Add read more link to the_excerpt?’ is closed to new replies.