Greenguy's Board


Go Back   Greenguy's Board > Blogs and Blogging
Register FAQ Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Rate Thread Display Modes
Old 2007-05-08, 03:44 AM   #1
Ms Naughty
old enough to be Grandma Scrotum
 
Ms Naughty's Avatar
 
Join Date: Aug 2003
Location: Australia
Posts: 1,408
Send a message via ICQ to Ms Naughty
Creating a post-specific sidebar

Thanks again to Walrus, I've discovered another way to tweak my blog so I thought I'd make a post about it for other lost souls such as myself.

You can code Wordpress so that the sidebar shows different things according to whether you're looking at a post or at the main page.

The code is:

Code:
<?php /* If this is the home page */ if (is_home()) { ?>
    <?php include (TEMPLATEPATH . '/nameofinclude1.php'); ?>
    <?php } ?>
	<?php /* If this is the post page */ if (is_single()) { ?>
    <?php include (TEMPLATEPATH . '/nameofinclude2.php'); ?>
You need to make individual includes for each thing you need to be different.

Say you want to link to a gallery pics in your sidebar but want one thing on the post page and something different on the main page. You'd create a separate php file with just the pic in it. You'd upload it into your theme directory and you'd change the name in the above code to whatever the include is called.

I don't know if this post will help anybody but I was so proud of working it out I thought I'd share.

I think I'm starting to get the hang of this
__________________
Promote Bright Desire
Ms Naughty is offline   Reply With Quote
Old 2007-05-08, 10:48 PM   #2
walrus
Oh no, I'm sweating like Roger Ebert
 
walrus's Avatar
 
Join Date: May 2005
Location: Los Angeles
Posts: 1,773
Send a message via ICQ to walrus Send a message via Yahoo to walrus
I'm really glad to see that you've gotten into customization of your blog the way you have. It's good to know I'm not alone.

Once you start playing around with it you start to realize the power of WP. While I have no proof, I believe the key to the duplicate content issue isn't doing things to keep the bots out like noindex / nofollow but to work on making your pages as different as possible.
__________________
Naked Girlfriend Porn TGP
free partner account
walrus is offline   Reply With Quote
Old 2007-05-09, 06:42 PM   #3
jayeff
Just because I don't care doesn't mean I don't understand!
 
jayeff's Avatar
 
Join Date: Sep 2006
Posts: 95
Send a message via ICQ to jayeff
The is_home function works very nicely in the sidebar. It used to work on pages themselves too and anyone looking around the codex is likely to find references to that functionality.

However, somewhere in the last couple of versions of WP, it stopped working except in the sidebar, so if anyone wants to do on a page, what you have done on your sidebar, the solution now is:
Code:
<?php if ($_SERVER['QUERY_STRING'] == '') { ?>
...whatever you want to display
<?php } ?>
This will identify your home page, because when you are on the home page, your address bar will read simply http://www.yourdomain.com/ or similar. That matches the empty query string condition. As you navigate around your site, even if you are displaying user-/se-friendly URL's, WordPress is actually translating the default ?=page6 or whatever. In other words the query string would not be empty.

With that knowledge and a little native cunning, you can adapt this code to put content on other specific pages too...
jayeff is offline   Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:09 AM.


Mark Read
Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
© Greenguy Marketing Inc