Single Post Customization
Dear support,
I am looking for a way to edit the single post template to match our design.
The handful of options that are available in the BeTheme settings are not sufficient for what we are trying to do.
At first I thought this would be a simple matter of adding a copy of single.php in my child theme, but posts.php uses template parts that are defined elsewhere.
Is there a way for me to edit, for instance, the content-post.php file from my child theme?
I see this file is being included in the functions.php, which can only be extended, rather then overwritten, so I'm not sure what the best practice is here.
Some examples of what I'd like to do:
- Remove social media buttons and love-button. So not hide them with css, but prevent these buttons from loading at all.
- Remove or edit the html from the top section that contains the Previous, Next, and Show all buttons.
- Remove Tags and Categories dropdown.
- Change html of the Related posts section.
- etc.
Thanks in advance!
I am looking for a way to edit the single post template to match our design.
The handful of options that are available in the BeTheme settings are not sufficient for what we are trying to do.
At first I thought this would be a simple matter of adding a copy of single.php in my child theme, but posts.php uses template parts that are defined elsewhere.
Is there a way for me to edit, for instance, the content-post.php file from my child theme?
I see this file is being included in the functions.php, which can only be extended, rather then overwritten, so I'm not sure what the best practice is here.
Some examples of what I'd like to do:
- Remove social media buttons and love-button. So not hide them with css, but prevent these buttons from loading at all.
- Remove or edit the html from the top section that contains the Previous, Next, and Show all buttons.
- Remove Tags and Categories dropdown.
- Change html of the Related posts section.
- etc.
Thanks in advance!
Comments
are you sure that you want to modify theme files? Because as we see, most of the things you want do can be easily done with simple css and you can do it in Theme options > Layout > Custom CSS & JS > Custom CSS section. CSS in our opinion is also much safer because is stored in database and won't be overwritten by any update.
yes, overriding files (content-post.php specifically) would be great. There is for instance no way to get the post date to display underneath the title for instance with css alone. Or to move the title underneath the image. Or to load full-width image thumbnails in the blog overview.
Also, it would be nice to have the option not to load the social media buttons. Yes, css can make them invisible, but they are still slowing down the page in the background.
I feel that the child theme is safe enough, in that it also won't be overwritten by any update.
So if there is a best-practice for modifying theme files such as content-post.php, I'd be very interested to know ( :
I am the developer for the site, but there is one thing specifically that I'd like help with.
Normally I will modify theme files by making a copy of them to my child theme and editing them there. The difference with content-post.php, is that it gets called in betheme's functions.php, which I can only extend in my child theme, and not overwrite. So my question is, how do I modify content-post.php, without altering the core theme file?
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-content/themes/my_childtheme/includes/content-post.php');
I recommend this code instead (WP way) :