I am having difficulty understanding how to use my own custom single-cptname.php file. I have created a child theme with a custom post type named product. I have successfully added the layout builder to the cpt. Now, I would like to define a custom single.php file to allow for more fine grain control of the output. I have tried to create a single-product.php file within my child theme but that seems to be ignored. I have tried to look at the enfold parent theme’s single-portfolio.php which uses an include/loop. Any help would be greatly appreciated.
Thanks for developing such a great flexible theme.
The single-cptname.php will work with a child theme and the parent theme and regardless which solution you use it will always load. The include/loop function is not obligatory – Kriesi uses it because it allows the user to customize the wp-contentthemesenfoldincludesloop-portfolio-single.php file within a child theme. The user just needs to create the includes/loop-portfolio-single.php file in the child theme folder and wp will automatically load this template instead of the parent theme file. But if you create the cpt template in the child theme folder youdon’t need to create loop files unless you’ve other reasons (several templates use the same loop template, etc.).
I’m not sure why it doesn’t work in your case but maybe your cpt conflicts with a plugin? Eg WooCommerce uses the cpt “product” too and you can’t easily create a custom template for WooCommerce products because the plugin uses several template_redirect hooks to bypass the standard wordpress template system…
The topic ‘Problems with single-cpt.php and custom custom post types [child theme]’ is closed to new replies.