Showing stuff only on your “individual” archive pages

I’m so used to the way MT works - switching to a different system is taking a little getting used to. (I told Matt that I need MT Rehab) ;o)

In any case - if you want something to show up only on a page where one post is displayed, wrap it in this code:

<?php if ($single) { ?>
YOUR STUFF TO DISPLAY ON THE “SINGLE POST” PAGE
<?php } ?>

7 Responses to “Showing stuff only on your “individual” archive pages”

  1. Rick Yribe Says:

    Nice tip.

  2. P Chuprina Says:

    Who is photo matt?

  3. Mark J Says:

    PhotoMatt is the “handle” of Matt, the original author of WordPress (which is, itself, not an original work… but let’s not get into semantics).

    I didn’t know about the $single trick… I’ve been using $name, which is true if you are viewing a single post (at least, I’m pretty sure it works the same as single… it has so far).

    Here are a few other useful variables. If you’re wondering where I found these, I just looked at the .htaccess rewrite rules.

    $submit == ‘Search’ (true if you come from a search and there were either 0 matches, or more than 1 match)
    $year will be set if the year is set
    $monthnum will be set if the month is set
    $day will be set if the day is set
    $name will be set if the post name is set
    $posts will be set if posts are going to be displayed…
    $page will be set if you are viewing a specific page of a post

    I’ve used this to generate an H2 according to what you are seeing. You can combine these to figure it out.

    Here is what I am currently using on my test blog. $pagetitle is the variable I use to display the H2 as well as part of the TITLE:

    if($submit == ‘Search’){
    $pagetitle = ‘Search Results’;
    } elseif (!$submit && !$posts) {
    $pagetitle = ‘No Entries Found’;
    } elseif (!$submit && !$year && !$monthnum && !$day && !$name && $posts){
    $pagetitle = ‘Tempus Fugit Blog’;
    } elseif (!$submit && $year && $posts && !$name){
    $pagetitle = ‘Archives ‘ . wp_title(’ยป’,FALSE);
    } elseif ($name && $posts){
    $pagetitle = wp_title(”,FALSE);
    }

  4. 8 Ways to Sunday Says:
    Scriptygoddess Takes WordPress by Storm
    Scriptygoddess’ Jennifer is learning WordPress in perparation for a migration of her well-known DIY weblog. In the process, she’s unearthing and sharing lots of great information and has just come out with her first WP plugin…

  5. Code Novice Says:
    WordPress Bookmarks
    A slew of WP bookmarks, plugins, etc. as seen on Scriptygoddess:

  6. paticoflange Says:

    Thanks A LOT. I’ve used the ‘if single’ before, but the code with a “!” before the “$” — there really is almost poetry to all this code stuff.

    PHP is awesome.
    WordPress is awesome.
    scriptygoddess is awesome.

  7. Steve Says:

    Thanks for this - just what I was after. I’ve switched from blogger and miss the tags!