Add if Condition that applies only in selected page template - Wordpress

The Wordpress Page templates conditions that will help you to use some files in particuler Page Template.


Many often you have to face jquery clashes with home page slider and inner page js (js for tabber, Accordian, Lightbox).

you can come out from this problem with page template condition.

Add This condition code at your header.php file




<?php if ( is_page_template('wp-gallery.php') ) { ?>
    // JS Files That clashes with Home Page Banner. 
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/pop/slimbox.js"></script>
<link rel="stylesheet" href="<?php bloginfo('template_directory'); ?>/pop/slimbox.css" type="text/css" media="screen" />
<?php }else{?>
    //Js Files taht are used outside of this page- template
<script type="text/javascript" src="<?php bloginfo('template_directory'); ?>/pop/sliderjs"></script>

<?php } ?>

Where, wp-gallery.php is my Newly created page template, wich is actually use Js files for the Lightbox effect of my site..

So by this way you can ridge from jquery clashesh in Page-templates.

Comments

Post a Comment