Archived topic
How to remove several elements on single post for specific category
5 replies · Started by mkjj on February 14, 2023
I know this sounds absolutely stupid, but this is what my customers wants: I have to remove several elements from single posts of a specific category: title, featured image, date, category link and navigation. I'm not quite sure what would be best practice in this case.
I could use quick and dirty CSS, but I don't like this approach.
I could use a layout element. This works fine for title and featured image, but not for date, category link and navigation (next/previous post).
I could create a custom template. That would do the trick, but I usually avoid modifications of template files. More often than not, GP provides a much better way (a hook, for example).
Any help would be very appreciated. Thank you!
Mike
Hi Mike,
You can try this filter:
https://docs.generatepress.com/article/option_generate_blog_settings/
Or you can create ablock element - post meta template to define a specific post meta template for certain category.
https://docs.generatepress.com/article/block-element-post-meta-template/
Hi Ying,
thank you very much. option_generate_blog_settings would effect the archive page, not the single post, right? Sounds very powerful, but will probably not do the trick here.
The block element - post meta template seems a great option. Unfortunately, I usually disable the block editor. I'm not a big fan of that thing. :-)
I think, I will go the CPT route using a customized template.
It's always amazing to see how many features GP provides. But sometimes it needs the good old custom template. :-)
Thanks again,
Mike
you are welcome :)
option_generate_blog_settings works for the single post as well, if you scroll down you can see the single options, eg:
https://docs.generatepress.com/article/option_generate_blog_settings/#options-%E2%80%98single_date%E2%80%99
Yikes! I should read more carefully. This is awesome! The code snippet gives me all the options that I need. Beautiful! :-)
Thank you very much. You never cease to surprise me!
Mike
Glad to hear that :)