Filter "the_content" Conditionally based on post/page name
/**
* conditionally serve template parts based on previously created page name
*
* @param $content
* @return mixed
*/
function my_the_content_filter($content) {
// created page/post name programatically before
if ($GLOBALS['post']->post_name == 'coupon-creator') {
get_template_part('templates/ccdash/ccdash-coupon-creator');
}
// otherwise returns the database content
return $content;
}
add_filter( 'the_content', 'my_the_content_filter' );