Not sure if this has been asked or not? Maybe I didn’t use the correct search words?
I love the search bar feature; however, is it possible to change how the search results appear? Like… having a featured product’s image show up in the results? If that is not possible, is it possible to change the search result hyperlinks (to the product) to a different color? Right now if I search for something, the results only show up in black text. It is hard to tell that the product’s title is a hyperlink.
Any help would be super appreciated.
@modelliva
- You can change search result titles by using Custom CSS like this:
.search .entry-title a {
color: red;
}
Of course change color to one that you want to use.
- To add featured images for search results you should edit
travelify_theloop_for_search
that you can find in travelify folder >> library >> structure.
And use this code for featured images:
<?php
if( has_post_thumbnail() ) {
$image = '';
$title_attribute = apply_filters( 'the_title', get_the_title( $post->ID ) );
$image .= '<figure class="post-featured-image">';
$image .= '<a href="' . get_permalink() . '" title="'.the_title( '', '', false ).'">';
$image .= get_the_post_thumbnail( $post->ID, 'featured', array( 'title' => esc_attr( $title_attribute ), 'alt' => esc_attr( $title_attribute ) ) ).'</a>';
$image .= '</figure>';
echo $image;
}
?>
And add it right above inside my above mentioned functions.
Sorry, but I am a bit confused about the search results featured image.
I do not understand "and add it right above inside my above mentioned functions?
I went to the structure folder and opened the content-extensions file. There are 3 results that come up for travelify_theloop_for_search
Does every travelify_theloop_for_search need the code? The above but inside part is really throwing me off.
Thanks for the search results color title fix. I was able to change that!
Ok, then add my above mentioned code on line 362 on that file right above this line of code:
<header class="entry-header">
Let me know if this helps.
While travelify_theloop_for_search
is mentioned 3 times it is a whole thing, the same function, with the same task.
I am assuming I am still doing something wrong because it didn’t work. I am attaching a screenshot for reference.