Advertisement
rmarksua

Template Override

Jan 17th, 2012
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.38 KB | None | 0 0
  1. <?php
  2.  
  3. add_filter('template_include', 'book_template_override_filter');
  4. function book_template_override_filter($template) {
  5.     if ( 'book' == get_post_type() ) {
  6.         if ( $theme_file = locate_template(array('single-book.php')) ) {
  7.             $file = $theme_file;
  8.         } else {
  9.             $file = plugin_dir_path(__FILE__) . 'views/single-book.php';
  10.         }
  11.         $template = $file;
  12.     }
  13.     return $template;
  14. }
  15.  
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement