WordPress.org

Ready to get started?Download WordPress

Forums

Different displays on different page types (3 posts)

  1. katkin
    Member
    Posted 10 years ago #

    I've found the following pretty helpful:
    <?php if ($single) { ?>
    Stuff you want only on a single post page
    <?php } ?>
    and
    <?php if (!$single) { ?&gt
    ;Stuff you want only on a non-single pages
    <?php } ?>

  2. katkin
    Member
    Posted 10 years ago #

    Oops. Second on should be:
    <?php if (!$single) { ?>
    Stuff you want only on a non-single pages
    <?php } ?>
    If you want to specify particular stuff for other archive pages too, you'd have to get a bit more complex but I find just the single and not-single to be fine for me.

  3. random
    Member
    Posted 10 years ago #

    Thanks, I knew about $single, it's the "bit more complex" part that's messing with me. :(
    At the moment I've added various $pagetype = 'month';, $pagetype = 'day'; type things to wp-blog-header.php. If $year isn't null then $pagetype is set as 'year'; Then $month is checked, and if not null then $pagetype is set as 'month', then $day etc.
    In the template pages I can put <?php if ($pagetype == 'month') { blah blah; } ?> etc.
    This works, but it's not very elegant and doesn't cover everything (search results, category views). And, obviously, editing files every time there's an upgrade is annoying. I'm not great with PHP, which is why I was hoping someone could point out something blindingly obvious that I've missed...

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.