- This topic has 9 replies, 2 voices, and was last updated 2 years, 1 month ago by David.
-
AuthorPosts
-
March 11, 2022 at 9:10 am #2151014Alicia
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?
March 11, 2022 at 9:41 am #2151063DavidStaffCustomer SupportHi 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 ?March 11, 2022 at 10:18 am #2151118AliciaThe 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.
March 11, 2022 at 10:22 am #2151126DavidStaffCustomer SupportThat’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
March 12, 2022 at 3:48 pm #2152465AliciaI’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.
March 13, 2022 at 5:22 am #2152745DavidStaffCustomer SupportOK – so do you currently have your Search Results displaying the CPT ?
March 13, 2022 at 2:37 pm #2153324AliciaHi 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!
March 14, 2022 at 5:52 am #2153887DavidStaffCustomer SupportGlad 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 itsgenerate_do_template_part
function as seen here in our archive templates including search.php:When you set a Block Element – Content Templates Display Rules, it will unhook the themes template part and hook itself in.
March 14, 2022 at 8:12 pm #2154775AliciaYes! I used the block element to replace the content on the 404 page. Excellent!!
March 15, 2022 at 3:48 am #2155092DavidStaffCustomer SupportAwesome – glad to hear that 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.