• Resolved semoliner

    (@semoliner)


    When using Relevanssi without “Create custom search result snippets” enabled, the search results appear as expected, with a clickable “Read More >>” link at the end of each search result in the list.

    But when “Create custom search result snippets” is enabled, there is no way to action any of the search results. There are no “Read More >>” links and nothing in the results themselves are clickable.

    Not sure what I’m doing wrong here. I really love the snippets and the way the search terms are highlighted in them, but can’t work out why they are not actionable.

    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)

    Relevanssi doesn’t, and isn’t supposed to, add a read more link to the end of the excerpt. Excerpt is an excerpt of the post, and the link to the post is a separate thing. WordPress default excerpts may include a read more link, but Relevanssi excerpts never do.

    If your search results template does not include a link to the post, you need to modify the search results template so that it does.

    Adding

    <a href="<?php the_permalink(); ?>">Read more</a>

    to your search results template at the suitable spot will create a link to the post.

    Thread Starter semoliner

    (@semoliner)

    Thanks for the quick response! While I can edit search.php, I really have no idea where to add that line (as I don’t understand the contents of search.php). I experimented by pasting in various places without success. Here is my standard Astra search.php, in case you are able to suggest where I need to paste it?

    <?php
    /**
     * The template for displaying search results pages.
     *
     * @link https://developer.www.ads-software.com/themes/basics/template-hierarchy/#search-result
     *
     * @package Astra
     * @since 1.0.0
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit; // Exit if accessed directly.
    }
    
    get_header(); ?>
    
    <?php if ( astra_page_layout() == 'left-sidebar' ) : ?>
    
    	<?php get_sidebar(); ?>
    
    <?php endif ?>
    
    	<div id="primary" <?php astra_primary_class(); ?>>
    
    		<?php astra_primary_content_top(); ?>
    
    		<?php astra_archive_header(); ?>
    
    		<?php astra_content_loop(); ?>		
    
    		<?php astra_pagination(); ?>
    
    		<?php astra_primary_content_bottom(); ?>
    
    	</div><!-- #primary -->
    
    <?php if ( astra_page_layout() == 'right-sidebar' ) : ?>
    
    	<?php get_sidebar(); ?>
    
    <?php endif ?>
    
    <?php get_footer(); ?>
    
    Plugin Author Mikko Saari

    (@msaari)

    The content loop is printed out by astra_content_loop(), so you can’t edit it here. This is a weird implementation, and even after looking at the source code, I can’t really help you out here. Astra support forums would be a better place to ask, I’m sure you can find people there who can help you with this.

    In Astra, the link to the post is in the title. Since the post titles are missing, so are the links. Not sure why they are missing on your site, default Astra settings do show the titles and the links.

    Thread Starter semoliner

    (@semoliner)

    Thank you – no wonder I couldn’t get it to work ??
    I appreciate your help with this and will refer to Astra support.

    Thread Starter semoliner

    (@semoliner)

    The solution to this was to add this to the functions.php file:

    add_action('wp', 'inital_call_back');
    
    function inital_call_back(){
    	if ( is_search() ) {
    		add_filter( 'the_excerpt', 'the_excerpt_more_link', 21 );
    	}
    
    }
    
    function new_excerpt_more($more) {
    	return '';
    	}
    	add_filter('excerpt_more', 'new_excerpt_more', 21 );
    	function the_excerpt_more_link( $excerpt ){
    	$post = get_post();
    	$excerpt .= '<p class="read-more"><a href="'. get_permalink($post->ID) . '">Read more ?</a></p>';
    	return $excerpt;
    	}
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘no Read More links in snippets results’ is closed to new replies.