Forums

is_page_template conditional (3 posts)

  1. frescova
    Member
    Posted 2 years ago #

    I'm having some issues with the conditional below, can someone please take a look at it? Based on the code I want it to display one stylesheet for either of the first two templates or a different one for either of the second 2. As it is now it always displays the first style sheet...

    <?php
    	if (is_page_template('digest.php' || 'digest-page.php')) {
    	?>
    	<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/customCss/digest.css" type="text/css" media="screen" />
    	<?php
    	}
    	else if (is_page_template('it.php' || 'it-page.php')) {
    	?>
    	<link rel="stylesheet" href="<?php bloginfo('template_url'); ?>/customCss/it.css" type="text/css" media="screen" />
    	<?php
    	}
    	?>
  2. frescova
    Member
    Posted 2 years ago #

    one minor addition - Ideally what I want is for all sub-pages of file-1.php or all sub pages of file-2.php to use the corresponding stylesheet,

    so if page template is file-1.php or any of its sub pages use css 1

    if page template is file-2.php or any of its sub pages use css 2

    Thanks in advance for any guidance...

  3. pirazolone
    Member
    Posted 2 years ago #

    Has someone found a way to make conditional CSS based on "is_page_template" to work? I am trying to load only css page "x" to certain templates...

    I was trying:

    <?php
    if ( is_page_template('single-video.php')) {
    echo '<link rel=”stylesheet” href=”',bloginfo("template_directory"),'/css/video.css” type=”text/css” />';
    } ?>

    or

    <?php
    if ( is_page_template('single-video.php')) { ?>
    <link rel=”stylesheet” href=”<?php bloginfo(‘template_directory’); ?>/css/video.css” type=”text/css”  />
    <?php } ?>

    to no avail... It seems not to even send it to the browser.

    Is this just not even possible (with or without the "echo" in the header)?
    (thinking that being pre-"Body", the php is not parsing... )

    Any hint in a direction would help...

Topic Closed

This topic has been closed to new replies.

About this Topic