Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
WordPress pagination: How to display sidebar content on front page only?
Old 01-11-2010, 09:49 PM WordPress pagination: How to display sidebar content on front page only?
Average Talker

Posts: 19
Name: Bob Jones
Trades: 0
I need to place sidebar content on my WordPress blog that appears on the home page only.

This means the content should display only at mysite.com and not at mysite.com/page/2/

However, both the home page and inside pages use the same template, index.php, which means they both use the same sidebar.

Is there a conditional script that would prevent my home page sidebar from appearing on inside pages?

Thanks.
slobjones is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 01-12-2010, 09:19 AM Re: WordPress pagination: How to display sidebar content on front page only?
racer x's Avatar
Ultra Talker

Posts: 457
Name: Randy
Location: Northern Wisconsin
Trades: 0
There are many conditional tags for Wordpress. See here: http://codex.wordpress.org/Conditional_Tags

You can place this code in your sidebar:

PHP Code:
<?php if ( is_home() ) { ?>
do something for the home page only
<?php ?>

Last edited by racer x; 01-12-2010 at 09:21 AM..
racer x is offline
Reply With Quote
View Public Profile Visit racer x's homepage!
 
Old 01-12-2010, 04:05 PM Re: WordPress pagination: How to display sidebar content on front page only?
Average Talker

Posts: 19
Name: Bob Jones
Trades: 0
My scripting is terrible, to say the least.

Would you see if you can correct this script? I'm trying to call sidebar-index.php for the front page and sidebar.php for /page/2/ and succeeding pages.

Code:
<?php
if ( is_front_page() && !is_paged() ) ?>
  <?php include("sidebar-index.php"); ?>
else
  <?php include("sidebar.php"); ?>
?>
slobjones is offline
Reply With Quote
View Public Profile
 
Old 01-12-2010, 04:57 PM Re: WordPress pagination: How to display sidebar content on front page only?
lizciz's Avatar
Super Spam Talker

Posts: 807
Name: Mattias Nordahl
Location: Sweden
Trades: 0
PHP Code:
<?php
if ( is_front_page() && !is_paged() )
  include(
"sidebar-index.php");
else
  include(
"sidebar.php");
?>
__________________
Your answers will only be as good as your question. Formulate it well and give all the necessary information.
lizciz is offline
Reply With Quote
View Public Profile Visit lizciz's homepage!
 
Old 01-12-2010, 05:26 PM Re: WordPress pagination: How to display sidebar content on front page only?
Average Talker

Posts: 19
Name: Bob Jones
Trades: 0
That worked!

Many thanks, lizciz.
slobjones is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to WordPress pagination: How to display sidebar content on front page only?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.21052 seconds with 12 queries