From 0ec4ece539233bc66aba5534e0b20a3ce8649901 Mon Sep 17 00:00:00 2001 From: StephenJCotton Date: Tue, 14 Feb 2017 14:30:19 -0500 Subject: [PATCH 1/2] Allow for alternative templates. --- inc/widget-custom-post-type-recent-posts.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/inc/widget-custom-post-type-recent-posts.php b/inc/widget-custom-post-type-recent-posts.php index 207e791..2aca886 100644 --- a/inc/widget-custom-post-type-recent-posts.php +++ b/inc/widget-custom-post-type-recent-posts.php @@ -37,6 +37,17 @@ public function widget( $args, $instance ) { 'ignore_sticky_posts' => true, ) ) ); + $possible_templates = array( + 'content-'.$this->alt_option_name.'.php' + ); + $template_found = false; + + foreach( $possible_templates as $a_possible_template ){ + if( locate_template( $a_possible_template ) ){ + $template_found = locate_template( $a_possible_template ); + } + } + if ( $r->have_posts() ) : ?> From ff72617553e03e4ca8b504fab346d901d55b6590 Mon Sep 17 00:00:00 2001 From: StephenJCotton Date: Tue, 14 Feb 2017 14:33:43 -0500 Subject: [PATCH 2/2] Allow for alternative templates for each post type. --- inc/widget-custom-post-type-recent-posts.php | 1 + 1 file changed, 1 insertion(+) diff --git a/inc/widget-custom-post-type-recent-posts.php b/inc/widget-custom-post-type-recent-posts.php index 2aca886..8901453 100644 --- a/inc/widget-custom-post-type-recent-posts.php +++ b/inc/widget-custom-post-type-recent-posts.php @@ -38,6 +38,7 @@ public function widget( $args, $instance ) { ) ) ); $possible_templates = array( + 'content-'.$this->alt_option_name.'-'.$posttype.'.php', 'content-'.$this->alt_option_name.'.php' ); $template_found = false;