Community Forums › Forums › Design Tips and Tricks › Customizing search results page for use with Relevanssi
This topic contains 24 replies, has 3 voices, and was last updated by Guter 3 months, 3 weeks ago.
-
AuthorPosts
-
January 1, 2013 at 1:24 pm #8787
I updated the code on the link. Let’s see if this gets closer. I added a priority because right now this is getting added after the sidebar. Then, I gave the strings some CSS based on Relevanssi’s documentation.
I gave it an ID of didyoumean, so you’ll need to add something like this to your child theme’s style sheet:
/* Relevanssi search result when nothing found */ #didyoumean { margin: 0 0 10px; padding: 0 30px; }That ought to make it line up with the other content. Adjust to suit your taste. Keep your fingers crossed

Twitter: @wpperform
January 1, 2013 at 3:14 pm #8816Wow, this is interesting. The updated code made the result appear at the top of the sidebar again. When I changed genesis_after_content back to genesis_before_content it went back into the post content area. With the css in place it now looks perfect.
A big thanks for all your time and advice!
January 1, 2013 at 5:58 pm #8853Glad it works. It looks good.
I think the priority caused the genesis_after_content not to work. The default priority is 10, and lower numbers mean higher execution priority, so maybe 5 was too low. You can delete the priority altogether, since it’s optional. I don’t understand the on-screen text, but if the order isn’t to your liking, you can try going back to the after content hook and upping the priority. That might put this text after the content, which I suspect says that the string wasn’t found. If you use use a tool like Firebug or right click on an element in Chrome and inspect it, you can see where it puts that ID, and the goal is to get it after the content but before the sidebar. The CSS won’t change.
Twitter: @wpperform
January 2, 2013 at 7:07 am #8927Thanks for your thoughts! Will give it a try.
January 2, 2013 at 7:21 am #8930Yep, I upped to priority to 10, changed the hook back to genesis_after_content and now everything is the way I want it to look.
I can’t thank you enough Bill for all your hand holding through this process.
January 2, 2013 at 8:46 am #8934January 2, 2013 at 2:24 pm #9019I just noticed that this solution is not mobile responsive. When using my iPad in portrait mode the Relevanssi output appears *below* the sidebar contents, just above the footer. I”ll try putting some additional css styling in the viewport for smaller displays. Maybe that will to the trick.
January 2, 2013 at 6:44 pm #9081That’s happening because right now, the order of the divs is content…sidebar…didyoumean (the Relevanssi function). You need to see if you can change that content…didyoumean…sidebar. Since the default priority is 10, try a priority that is > 5 but < 10 to see if that helps get that order. (You can see the order using a tool like Firebug for Firefox.)
With the right order, it is a matter of then adjusting the mobile responsive styling for the didyoumean ID's, which will be found in a series of media queries at the bottom of your child theme's stylesheet. In general, didyoumean should have the many of the same properties as #content.
Twitter: @wpperform
January 3, 2013 at 5:01 am #9136Thank you Bill. Will try and experiment a bit to find the best result.
January 29, 2013 at 2:00 pm #16079Guys, you are simply wonderful. Thank you very much for your great dialogue. Here you are my final code:
// add to child theme functions.php after the call to init.php and before the closing tag (if it exists)
add_action('genesis_before_content', 'wpp_relevanssi_did_you_mean', 5);
function wpp_relevanssi_did_you_mean() {
if ( is_search() ) {
if (function_exists('relevanssi_didyoumean')) {
relevanssi_didyoumean(get_search_query(), "<div id='didyoumean' style='font-size:20px; padding-bottom:10px;'>Forse intendevi: ", "</div>", 5);
}
}
}I’d like to show you final result but the site is in development and well… “Forse intendevi” is italian!
Thank you!
-
AuthorPosts
The topic ‘Customizing search results page for use with Relevanssi’ is closed to new replies.