• Resolved kjeft

    (@kjeft)


    Hi all,

    I am just learning php (great fun by the way!) and here is my messy code I can’t get to work. I know it’s probably dead simple but my bloginfo just won’t be interpreted as php but instead as part of the html link. (i.e. <?php bloginfo(template_directory); ?> will be written in my sourcecode)

    <?php if ( is_page(news) || $post->post_parent == '68' ) {
    	echo '<link rel="stylesheet" href="<?php bloginfo(template_directory); ?>/style/css/news.css" type="text/css" media="screen" />';
    } ?>

    Please help me type this properly, I have tried different ” and ‘ characters but I tend to get it wrong every time!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You don’t need the php tags when you;re already inside a php block. Try:

    <?php if ( is_page(news) || $post->post_parent == '68' ) {
    	echo '<link rel="stylesheet" href="' . get_bloginfo(template_directory) . '/style/css/news.css" type="text/css" media="screen" />';
    } ?>
    Thread Starter kjeft

    (@kjeft)

    Worked perfectly! Thank you esmi!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘php and html mixup’ is closed to new replies.