• Resolved calmkiwi

    (@calmkiwi)


    How to show products and pages/posts in different sections in search results?

    If I use the search product widget, search results have the “Add to cart” button and doesn’t have any posts.
    If I use the global search widget, products and posts/pages are all mixed up, and there is no “Add to cart” button.

    I want products to show in one section, with the “Add to cart” buttons, and then posts/pages to show down below.

    Like this:

    h2>Products matching “blue”
    [product1] [product2] [product3]
    (all with the add to cart button)

    h2>Posts / pages matching “blue”
    [page1] [page2] [page3]

    I am surprised I can’t do this easily. Thank you for your support.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hey @calmkiwi,

    This is something that is possible but will take some custom coding. You’ll need to create a custom search results template in your theme (search.php). Then you’ll need to break the search results up into different loops so you can group and style them differently.

    There is a Stack Exchange post that shows one way you could approach that.

    https://wordpress.stackexchange.com/questions/181789/group-search-results-by-post-type

    It’s a great idea, but implementing it will take a moderate amount of coding. I hope that gets you pointed in the right direction.

    Cheers

    Howdy @calmkiwi,

    It’s been a while since we heard from you, so I’m marking this thread resolved. Hopefully, you’ve been able to resolve this, but if you haven’t, please let open up a new topic and we’ll be happy to help out.

    Thread Starter calmkiwi

    (@calmkiwi)

    Hi,

    Thanks for your reply. The amount of customization needed will create a maintenance problem. Please allow us to do it in an easier way by creating different widgets.
    Thanks.

    Hi @calmkiwi,

    This will take some custom work to create. I don’t think we’ll see this as a feature in the WooCommerce core. The best option would be to custom create this for your site. If you don’t want to do that on your own, there are freelance developers at Codeable who could add this to your theme.

    Thanks

    Thread Starter calmkiwi

    (@calmkiwi)

    Search is a major part of any site. Creating a search system that returns products separated from blog posts and pages should 100% be in Woocommerce Core. The way you have it today all mixed up is atrocious for 2020’s standards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘How to show products and pages/posts in different sections in search results?’ is closed to new replies.