Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress Build a Website with WordPress Customizing WordPress Themes Customizing WordPress Theme Files

Keith Bennett
PLUS
Keith Bennett
Courses Plus Student 253 Points

Is it possible to remove the comment area in a separate PHP file?

You copied and modified the page.php file to remove the comment area. However, won't this be a problem if an update to the theme changes page.php?

Is there a way for the child theme to import the parent theme's page.php and then in the child theme's page.php, remove/disable the comment area?

1 Answer

Jonathan Arbely
Jonathan Arbely
6,691 Points

Hello Keith, yes indeed, that would be a problem!

And yes, this can be done by using child-themes. Take a look. The easiest way of hiding the comment-section for good would be to hide it in the style.css of your child-theme with display: none;.

But a better solution is to use a plugin (like JetPack - caution, adds a lot of potentially unnecessary weight to your site) that lets you create and edit a custom stylesheat wihout the need to create and manage a child-theme. This seems overkill just to hide the section of a page. Speaking of pages and posts, WordPress has a built-in feature which let's you hide the comment section from a page or post while creating/editing it. Are you aware of that?