• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

My Monkey Do

A Log of Coding Solutions

  • Home
  • Web Hosts
  • Tools
  • About

How to use your own template for specific times

December 14, 2012 by Webhead

There’s a great post on how to get WordPress to use your own template and override the default template.

The basic code looks like this;

function my_template() {
if (is_category() && get_query_var(‘cat’) == get_cat_id(‘fun’)) {
include (TEMPLATEPATH . ‘/category-fun.php’);
exit;
}
}

add_action(‘template_redirect’, ‘my_template’);

 

Be sure to use STYLESHEETPATH instead of his TEMPLATEPATH so that child themes respond to the code properly.

http://www.mihaivalentin.com/wordpress-tutorial-load-the-template-you-want-with-template_redirect/

Filed Under: Coding Tagged With: php, wordpress

Primary Sidebar

Topics

apache apple block editor chrome cms css debug eCommerce embed firebug firefox git gmail goDaddy google hosting htaccess html html 5 IE crap image iPad iPhone javascript jquery linux localization mac os x ms sql mysql open source optimize php php 5.3 responsive rest api seo svg tinymce woocommerce wordpress wpengine xss yii youtube




Categories

  • Coding
  • Off the Shelf
  • Plugins
  • Random Thoughts
  • Server Stuff
  • Tools