Community Forums › Forums › Archived Forums › Design Tips and Tricks › How to edit the search results template?
- This topic has 4 replies, 3 voices, and was last updated 9 years ago by robertdabarnes.
-
AuthorPosts
-
April 14, 2013 at 1:30 am #35345robertdabarnesMember
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 http://www.superguide.com.au
Thanks in advance
Cheers, Rob
April 15, 2013 at 4:33 pm #35645Brad DaltonParticipantYou 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.
April 16, 2013 at 1:39 am #35724robertdabarnesMemberThanks 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
April 7, 2015 at 1:33 pm #146956asterbirdMemberHi 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 http://adamcap.com/code/filter-genesis-h1-post-titles-to-add-for-styling/ 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 the_excerpt(); // 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!
April 7, 2015 at 10:52 pm #147017robertdabarnesMemberThanks Asterbird - I've since moved back to Google Custom Search Engine, but thanks for taking the time to let me know.
Cheers, Rob
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.