Archived topic
PHP Function to remove entry header
16 replies · Started by Fabien on June 11, 2020
Hi,
Is there a php function to remove the entry-header within a post ?
Thanks !
Hi there,
So you want to remove the post title and entry meta?
Would this for both the posts page and single post?
Yes, I want to remove the div.entry-header (and it's content : title, featured image, meta) using a PHP function. I will target specific post type.
Thanks
Hi there,
there isn't a hook for removing the entry-header container.
To do that you would need to create a custom template of the content-single and remove that HTML element:
https://github.com/tomusborne/generatepress/blob/master/content-single.php
Thanks David ! I think having function would be nice ;-) Could that be added in the roadmap ?
As the entry-header is a core element of the single post - removing it feels like a custom template is required. But i will mention it to Tom :)
Yes it would make sense instead of having empty html tags : https://share.getcloudapp.com/GGuoAKzo
Hi @Tom,
Any updates on this ? It would make sense to be able to remove it with a function.
Thanks
Hi there,
Yes, this filter was added in 3.0: https://github.com/tomusborne/generatepress/blob/3.0.2/inc/theme-functions.php#L148
So you can do this:
add_filter( 'generate_show_entry_header', function( $show ) {
if ( $my_condition ) {
$show = false;
}
return $show;
} );
Awesome Tom !
Glad I could help :)
Hi, I am looking to remove the entry header from the published post.
I am new to GeneratePress, so apologies for my ignorance.
I see that a "filter" shown above was added in 3.0 - but what do you need to do to use it.
I tried pasting the "so you can do this" code in my child theme Functions.php file, but that did not work, so I tried pasting it in the custom CSS but again that did not work.
Please advise.
Thanks
Hi Edmund,
This is how you add PHP :)
Adding PHP: https://docs.generatepress.com/article/adding-php/
Hi Ying,
Thank you for your reply. I did try pasting into Functions.php of my child theme, but it did not work.
However I have since found the solution on each "Page" in Wordpress, in the toolbar on the right, has at the bottom, "disable elements" one of which is the content Title.
So that worked for me.
You can try creating a layout element if you need to do that globally:
https://docs.generatepress.com/article/layout-element-overview/#disable-element