Skip to content

Commit

Permalink
handle situation where post type is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
alexkingorg committed Jul 18, 2013
1 parent c276450 commit c66a01d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.txt
Expand Up @@ -4,6 +4,8 @@

- Add support for "sticky" posts (sticky.php, single-sticky.php, feed-sticky.php) in the post context
- Set default context to archive instead of home
- Properly load type-* templates in General context
- Requires WordPress 3.6 (for get_post() returning global $post)

## 3.4

Expand Down
5 changes: 5 additions & 0 deletions utility.php
Expand Up @@ -489,6 +489,11 @@ function cfct_choose_general_template_type($dir, $files) {
$files = cfct_type_templates($dir, $files);
if (count($files)) {
$type = get_query_var('post_type');
// post type not always set in query var - let's make a guess
if (empty($type)) {
$post = get_post(); // requires WP 3.6
$type = $post->post_type;
}
$file = 'type-'.$type.'.php';
if (in_array($file, $files)) {
return $file;
Expand Down

0 comments on commit c66a01d

Please sign in to comment.