Last active
August 29, 2015 14:05
-
-
Save thisislawatts/fd9b7f8efce659a3390a to your computer and use it in GitHub Desktop.
WordPress Faux Pages
This file contains hidden or 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 | |
/** | |
* project filters | |
* | |
* @package project | |
*/ | |
function project_page_title( $title, $sep ) { | |
global $wp_query; | |
if ( $wp_query->get('project_title') ) | |
return $wp_query->get('project_title') . " $sep "; | |
return $title; | |
} | |
add_filter('wp_title', 'project_page_title', 10, 2 ); | |
function project_faux_pages( $template ) { | |
global $wp_query; | |
$project_pages = array( | |
array( | |
'slug' => 'styleguide', | |
'title' => __('Styleguide', 'project') | |
), | |
array( | |
'slug' => 'people', | |
'title' => __('People', 'project') | |
) | |
); | |
foreach ( $project_pages as $page ) { | |
if ( $_SERVER['REQUEST_URI'] == "/{$page['slug']}" || $_SERVER['REQUEST_URI'] == "/{$page['slug']}/" ) { | |
status_header(200); | |
$wp_query->set( 'project_title', $page['title'] ); | |
return locate_template( array( $page['slug'] . '.php' ) ); | |
} | |
} | |
return $template; | |
} | |
add_filter( 'template_include', 'project_faux_pages', 9 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment