Loading content from template-parts
-
Hello,
Can someone please help? I need to create a specific template for a page called Events, but I can’t figure out how to do this.
The theme is using template parts.This is the instructions in the index.php page:
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', get_post_format() );
I’ve created a new template by copying the page.php page and calling it page-events.php.
It includes this line:
<?php get_template_part( 'template-parts/content', 'page', 'events' ); ?>
I’ve added the template to the page in WordPress dashboard. BUT, my problem is I can’t seem to connect it to the content.
The content of the template sits in a subfolder called “template-parts”.
I’ve added a new page there based on content-page.php and renamed it content-page-events.php.
But, whatever i put in the template file it does not show up. I’ve tried all sorts of variations like:
‘template-parts/content’, ‘page’, ‘events’
‘template-parts/content’, ‘page-events’, ‘events’
‘template-parts/content’, ‘page-events’
and so on, but not been able to read it. Can someone please tell me what the correct way to do this is?
- The topic ‘Loading content from template-parts’ is closed to new replies.