For a conditional based on the page, use is_page(). For one based on the page template being used, use is_page_template().
http://codex.wordpress.org/Conditional_Tags
Thanks. So you have to put all the conditional code in the header? Is that more efficent than having a “tag” in the header that pulls in conditional code from the pages? There is no way to do that?
I’m now trying to add this to the header, but keep getting syntax errors:
<?
if (is_page_template('homepage.php'))
{
echo "<script src='<?php bloginfo("template_directory"); ?>/js/sifr.js' type='text/javascript'></script>
<script src='<?php bloginfo("template_directory"); ?>/js/sifr-config.js' type='text/javascript'></script>";
}
?>
I’ve tried all the different combinations of ‘ and ” I could come up with. Nothing works. Am I missing something?
This doesn’t work either:
<?
if (is_page_template('homepage.php'))
{
echo '<script src="<?php bloginfo('template_directory'); ?>/js/sifr.js" type="text/javascript"></script>';
echo '<script src="<?php bloginfo('template_directory'); ?>/js/sifr-config.js" type="text/javascript"></script>';
}
?>
This solves the syntax problem:
<?
if (is_page_template('homepage.php'))
{
echo '<script src="<?php bloginfo("template_directory"); ?>/js/sifr.js" type="text/javascript"></script>';
echo '<script src="<?php bloginfo("template_directory"); ?>/js/sifr-config.js" type="text/javascript"></script>';
}
?>
But this is what ends up in the rendered html:
<script src="<?php bloginfo("template_directory"); ?>/js/sifr.js" type="text/javascript"></script><script src="<?php bloginfo("template_directory"); ?>/js/sifr-config.js" type="text/javascript"></script>
This works:
<?
if (is_page_template('homepage.php'))
{
echo '<script src="'. get_bloginfo('template_directory').'/js/sifr.js" type="text/javascript"></script>';
echo '<script src="'. get_bloginfo('template_directory').'/js/sifr-config.js" type="text/javascript"></script>';
}
?>
De-nested and using get_bloginfo instead of bloginfo