[Resolved] Would love to profoundly customize my search results page.

Home Forums Support [Resolved] Would love to profoundly customize my search results page.

Home Forums Support Would love to profoundly customize my search results page.

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #2151014
    Alicia

    Hello!

    I’m trying to get my search results to look like this page:

    https://dharmacomics.leahpearlman.com/comic-category/in-the-flesh/

    I’ve already tried with the block element, but I need to add custom fields to my query. And also add more HTML.

    It there a way to do this with a hook element?

    #2151063
    David
    Staff
    Customer Support

    Hi there,

    the Block Element – Content Template supports Custom Fields, and if need be you can include a HTML block within it.
    But looking at the example – what exactly is it your missing ?

    #2151118
    Alicia

    The image I’m using isn’t the featured image. It’s the image uploaded for the comic via custom field. I’ve learned from the error of my ways: USE featured image already built into WordPress. But, it’s too late, there are over 700 comics. It’s easier to add the custom field.

    #2151126
    David
    Staff
    Customer Support

    That’s ok.
    If you use a Block Element the dynamic data supports custom fields ( aka Post Meta ).
    So for example you can set the background image of a container using one:

    https://docs.generatepress.com/article/dynamic-data/#dynamic-background

    Or if you use the GP Dynamic Image Block it too can use a Post Meta field:

    https://docs.generatepress.com/article/dynamic-blocks/#featured-image

    #2152465
    Alicia

    I’m still confused. The content I’m trying to show is a custom post type called comic. I’m using ACF for the image upload. I can’t see a way to choose a custom post type with the two options above.

    #2152745
    David
    Staff
    Customer Support

    OK – so do you currently have your Search Results displaying the CPT ?

    #2153324
    Alicia

    Hi David!

    I went old school and creating a custom search template file in the theme. From there, I was able to do exactly what I needed. If there was another way around this, would love to know.

    This is what I love so much about GeneratePress! I’m able to do some really geeky template stuff or hook things in. Thanks for such an amazing theme!

    #2153887
    David
    Staff
    Customer Support

    Glad to hear that – and it sounds like the most appropriate solution for your need.

    The Block Element – Content Template would not define the custom search template or the query args for specifying the post type.
    It simply replaces the Template Part which GP would have requested using its generate_do_template_part function as seen here in our archive templates including search.php:

    https://github.com/tomusborne/generatepress/blob/a3ce1712ab1cc705fed577fad8fa9ea8c04d5d20/search.php#L37

    When you set a Block Element – Content Templates Display Rules, it will unhook the themes template part and hook itself in.

    #2154775
    Alicia

    Yes! I used the block element to replace the content on the 404 page. Excellent!!

    #2155092
    David
    Staff
    Customer Support

    Awesome – glad to hear that 🙂

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.