Overriding news.php in Child Theme for Future Scheduled News Posts
-
Hi everyone,
I'm currently working on creating a child theme for Laytheme. I have successfully set up my child theme with its own style.css, functions.php, and header.php. However, I'm encountering an issue with overriding the "news" functionality.
I use the news element as a kind of calendar to display events, and I need the events to be sorted by date, including future-scheduled posts (currently, only published posts are shown). I've modified the query in news.php to include future posts by changing the query parameter from:
'post_status' => 'publish',
to:
'post_status' => array('publish', 'future'),
and I also implemented a custom sorting function to order the events by date. However, despite copying the entire /news folder (with my modified news.php) into my child theme using the same folder structure, my changes don't seem to take effect—the parent theme’s version of news.php is still being loaded.
It appears that the parent theme includes the file using a direct require call like this:
require get_template_directory() . '/news/news.php';
I have read several times that Laytheme might not be fully designed with child themes in mind, which could be causing this issue. I’m looking for a method to override news.php in a child theme without modifying the parent theme’s files directly. Or maybe I am overcomplicating things and there is a much easier way to achieve what I am looking for.
Has anyone encountered this issue or found a solution to ensure that future-scheduled news posts are displayed and sorted by date while using a child theme? Any help or suggestions would be greatly appreciated.
Thanks in advance!
1/1
Before you post:
- When using a WordPress Cache plugin, disable it or clear your cache.
- Update Lay Theme and all Lay Theme Addons
- Disable all Plugins
- Go to Lay Options → Custom CSS & HTML, click "Turn Off All Custom Code", click "Save Changes"
This often solves issues you might run into
When you post:
- Post a link to where the problem is
- Does the problem happen on Chrome, Firefox, Safari or iPhone or Android?
- If the problem is difficult to explain, post screenshots / link to a video to explain it