Skip to content

Instantly share code, notes, and snippets.

@Gipetto
Created February 20, 2012 23:47
Show Gist options
  • Save Gipetto/1872357 to your computer and use it in GitHub Desktop.
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
<?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