scriptygoddess

21 May, 2004

Showing stuff only on your "individual" archive pages

Posted by: Jennifer In: WordPress: Lessons Learned

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"

2 | P Chuprina

May 22nd, 2004 at 9:52 am

Avatar

Who is photo matt?

3 | Mark J

May 23rd, 2004 at 6:27 am

Avatar

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

May 23rd, 2004 at 7:47 pm

Avatar

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

May 31st, 2004 at 5:35 pm

Avatar

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

6 | paticoflange

July 30th, 2004 at 1:20 pm

Avatar

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

January 17th, 2005 at 1:37 pm

Avatar

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

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements