How to edit the search results template?

Community Forums Forums Design Tips and Tricks How to edit the search results template?

This topic is: not resolved

This topic contains 4 replies, has 3 voices, and was last updated by  robertdabarnes 7 months, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
  • #35345


    Hi – I’m trying to use Relevanssi for my site search, but part of isn’t working (it’s replacing the links for tags with /other which is my ‘uncategorized’ category).

    It looks like it could be because of the following:

    In the search results template, avoid get_permalink(), as it doesn’t work. the_permalink() works and returns the correct permalink. You can use relevanssi_get_permalink(), if you don’t want to echo the permalink directly.

    Please could somebody tell me how to edit my search results template? I did search for instructions in the forum but no luck.

    By the way my site is

    Thanks in advance

    Cheers, Rob



    You should never edit the core Genesis files.

    Google custom search is a better solution as its far more accurate and easier to customize and install.



    Thanks Brad – I’ve used Google custom search with a different theme but I’ve had various issues when trying it with Genesis. I don’t want to detail them all here because I’d rather just see if there is a way to get Relevanssi to work since it gives me much more control.

    So if Genesis does use get_permalink() whether there is any way that I can change it to the_permalink() without editing the core files? Would this be a custom hook or custom function?

    Cheers, Rob



    Hi Rob,

    I know this is a little late, but I found a solution and wanted to share…

    I was able to switch out get_permalink() for relevanssi_get_permalink() by adding the following to my child theme’s search.php (if you don’t have one, copy the one from Genesis core and paste it into your child theme folder):

    //* Modify post titles to add Relevanssi permalink
    // help from
    add_filter( 'genesis_post_title_output', 'child_post_title_output', 15 );
    function child_post_title_output( $title ) {	
            // change h2 to h1 depending if you have a search page title or not	
    	$title = sprintf( '<h2 class="entry-title" itemprop="headline"><a href="%s" rel="bookmark">%s</a></h2>', esc_url( relevanssi_get_permalink() ), apply_filters( 'genesis_post_title_text', get_the_title() ) );
    	return $title;

    I was doing Woocommerce as well, so some of this might not apply…

    // Modify content to add Featured Images and Relevanssi permalink
    remove_all_actions( 'genesis_entry_content' );
    add_action( 'genesis_entry_content', 'child_do_post_excerpt' );
    function child_do_post_excerpt() {
    	// Get featured image if page or post
    	the_post_thumbnail( 'medium', array( 'class' => 'alignright' ) );
    	// Get featured image if WooCommerce product category
    	global $post;			
    	$thumbnail_id = get_woocommerce_term_meta( $post->term_id, 'thumbnail_id', true );
    	echo wp_get_attachment_image( $thumbnail_id, 'medium', '', array( 'class' => 'alignright' ) );
    	// Get excerpt rather than the_content() so Relevanssi can grab a snippet and highlight search terms
    	// Get 'Read More' link with Relevanssi permalink
        echo '<a class="read-more-link" href="' . esc_url( relevanssi_get_permalink() ) . '">View more »</a>';

    Hope that helps!



    Thanks Asterbird – I’ve since moved back to Google Custom Search Engine, but thanks for taking the time to let me know.

    Cheers, Rob

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.