Customizing search results page for use with Relevanssi

Community Forums Forums Design Tips and Tricks Customizing search results page for use with Relevanssi

This topic is: resolved

This topic contains 24 replies, has 3 voices, and was last updated by  Guter 1 year, 6 months ago.

Viewing 10 posts - 16 through 25 (of 25 total)
  • Author
    Posts
  • #8787

    Bill Murray
    Participant
    Post count: 572

    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:

    [css]
    /* Relevanssi search result when nothing found */
    #didyoumean { margin: 0 0 10px; padding: 0 30px; }
    [/css]

    That ought to make it line up with the other content. Adjust to suit your taste. Keep your fingers crossed :)


    Web: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #8816

    lostintime
    Participant
    Post count: 55

    Wow, 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!

    #8853

    Bill Murray
    Participant
    Post count: 572

    Glad 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.


    Web: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #8927

    lostintime
    Participant
    Post count: 55

    Thanks for your thoughts! Will give it a try.

    #8930

    lostintime
    Participant
    Post count: 55

    Yep, 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.

    #8934

    Bill Murray
    Participant
    Post count: 572

    Glad it worked out the way you wanted.


    Web: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #9019

    lostintime
    Participant
    Post count: 55

    I 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.

    #9081

    Bill Murray
    Participant
    Post count: 572

    That’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.


    Web: http://wpperform.com or Twitter: @wpperform

    We do managed WordPress hosting.

    #9136

    lostintime
    Participant
    Post count: 55

    Thank you Bill. Will try and experiment a bit to find the best result.

    #16079

    Guter
    Participant
    Post count: 1

    Guys, 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!


    My Last Work: Studio Notarile Arcoleo

Viewing 10 posts - 16 through 25 (of 25 total)

The topic ‘Customizing search results page for use with Relevanssi’ is closed to new replies.