treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Wordpress: if page = single

  • I'm using wordpress. I want to add certain code to the header when someone is browsing an article page (which uses the page.php template). I've done something similar (not in wordpress) before by having this in the header:
    <?php if ($current_page == \"gallery\") { ?>
    <link rel=\"stylesheet\" type=\"text/css\" href=\"css/gallery.css\" />
    <?php } ?>

    And this in the page:
    <?php $current_page = \"gallery\"; ?>

    I've tried that but it's not working in wordpress. Any ideas?
  • <?php if (is_page()) {

    ...stufff...

    <?php } ?>
  • You forgot to close off the top line with ?>
    Here it is for anyone else who wants to know:
    <?php if (is_single()) { ?>

    ...stufff...

    <?php } ?>

    Thanks a lot Chris.