Created
February 20, 2012 23:47
-
-
Save Gipetto/1872357 to your computer and use it in GitHub Desktop.
Enable Carrington Theme Framework to contextually load page content templates by page name
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Allow content templates to be loaded by page name | |
* | |
* ie: a page named "home" can load a special content template by adding a file | |
* to the content templates folder: `content/page-home.php` | |
* | |
* @param string $filename | |
* @param string $type | |
* @return string | |
*/ | |
function _choose_content_template_by_page_name($filename, $type) { | |
global $post; | |
if ($type == 'content' && $post->post_type == 'page') { | |
if (file_exists(CFCT_PATH . $type . '/page-' . $post->post_name . '.php')) | |
$filename = 'page-' . $post->post_name . '.php'; | |
} | |
return $filename; | |
} | |
add_filter('cfct_choose_content_template', '_choose_content_template_by_page_name', 999, 2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment