August 16, 2023

Create a GeneratePress Search Page with GenerateBlocks

Play Video
Tutorial Walkthrough
This video tutorial provides an in-depth walkthrough, and we recommend following along with the video to grasp the concept fully. Below, you'll find a summary of the tutorial, but please note that it may leave out some detailed steps, so watching the video will give you the most comprehensive understanding.

Explore how to set up an efficient GeneratePress search page on your website using GenerateBlocks. Dive into the challenges of WordPress’s default search and discover plugins and SEO techniques to optimize user experience.


The Problem with WordPress’s Default Search

WordPress’s default search sometimes feels like it’s playing hide and seek:

  • Accuracy
    It doesn’t always find what you’re looking for.
  • User Experience
    The results layout can be a bit…meh.

Setting Up GeneratePress Search Results with GenerateBlocks

Here’s where the magic happens:

  1. Enable Default Search in GeneratePress
    Head over to the customizer, navigate to layout > primary navigation, and activate the navigation search modal.
  2. Customize the Layout with GenerateBlocks
    Add a section and insert a headline. Use the query loop block to display search results. This is where you shape how your search results look.
  3. Add Featured Images
    Visuals always help. Add a grid inside the query loop and link it to the post’s featured image. It gives users a quick peek into the content.

Enhancing User Experience with Search Titles

Let’s make the search results more intuitive:

  • Display the Search Query
    It’s always good to remind users what they searched for. Add a header that echoes back their search term.
  • Customization with Shortcodes
    A little technical, but super useful. Use a shortcode block to tweak the search results header. Below you will find a code snippet to display your search term:

    add_shortcode('search_title', 'get_search_title');
    function get_search_title() {
        if (is_search()) {
            return '<p class="search-for">Search results for:</p><h1 class="search-title">' . get_search_query() . '</h1>';
        } elseif (is_archive()) {
            return '<h1 class="search-title">' . get_the_archive_title() . '</h1>';
        } 
    }

    Source: GenerateTweaks


Handling ‘No Search Results’ Scenarios

It’s like when you can’t find your favorite cookie in the jar:

  1. Custom Message
    A friendly “Oops! We couldn’t find any results.”
  2. Encourage Another Search
    Maybe they misspelled it? Prompt users to try again. To have the last search term showing you can add the following to your HTML code:

    data-gpmodal-trigger="gp-search"

    Source: GenerateTweaks


Leveraging SEO for Better GenerateBlocks Search Results

SEO isn’t just for Google. It can make your site’s search smarter:

  1. Use Post Meta for Titles
    Instead of the default, why not fetch the SEO title?
  2. Fetch SEO Descriptions
    A brief SEO description can be more informative than the default excerpt.

Conclusion

With GeneratePress and GenerateBlocks, you can transform your website’s search function into a powerful and user-friendly feature. It’s all about making sure your visitors find what they’re after. Here’s to better searching!

Required Resources

GeneratePress Logo
Free Options
GenerateBlocks Logo
Free Options
Credit to The Admin Bar
The Admin Bar is a resourceful platform dedicated to WordPress. From insightful videos on optimizing your WordPress tech stack to creative hacks for faster web page creation, the channel is a treasure trove for both beginners and advanced WordPress users.
Visit
Create a GeneratePress Search Page with GenerateBlocks
Welcome back!
Enter your Helwp credentials to sign in.

No Account yet? Sign Up

My Account
Menu
Give Feedback
Describe your feedback *
Rate Helwp
Share
Facebook
Twitter
LinkedIn
Reddit
Email
WhatsApp
Telegram
Pocket
Report
Problem *
Describe the problem
Want us to reply?
Your E-Mail
Affiliate Disclosure

At Helwp, we’re committed to transparency and honesty. Therefore, we want to inform you that some of the links on our website are affiliate links. This means that, at no additional cost to you, we may earn a small commission if you click through and make a purchase.

We only promote products or services that we genuinely believe in. These affiliate commissions help us to maintain the website and continue to provide you with free, high-quality WordPress content.

If you are interested in how you can support us even further, check out our support page.