Displaying Sidebar Widgets on Homepage Only

Discussion in 'WordPress' started by Borduhh, Mar 13, 2011.

  1. #1
    Hello All,

    I am looking to display parts of my sidebar on my homepage only and other parts only when a person navigates away from my homepage. To do this I was thinking that an PHP if statement should be used, however I don't know what wordpress function will be used with this.

    For Example:
    <? PHP if <Wordpress Homepage Function> ?>{
    PHP:
    Hompage Content Only
    }​
    <? PHP else ?>{
    PHP:
    NON-HOMEPAGE CONTENT
    }​
    <? PHP Endif ?>
    
    PHP:
    Any Suggestions?

    Best Regards,
    Nick
     
    Borduhh, Mar 13, 2011 IP
  2. Borduhh

    Borduhh Well-Known Member

    Messages:
    767
    Likes Received:
    31
    Best Answers:
    0
    Trophy Points:
    150
    #2
    Hey All,

    Here is the code for the sidebar:

    
    <div id="sidebar">
        <div id="sidebar-top">
            <h3>Weekly Poker Training</h3>
            <div id="sidebar-content">
            <?php query_posts("showposts=2&cat=25"); $i = 1; ?>
            <?php while (have_posts()) : the_post(); ?>
                <div class="clearfloat">
                    <?php $values = get_post_custom_values("Image");
                    if (isset($values[0])) { ?>
                        <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>">
                        <img src="<?php echo bloginfo('template_url'); ?>/scripts/timthumb.php?src=/<?php
                        $values = get_post_custom_values("Image"); echo $values[0]; ?>&w=100&h=65&zc=1&q=100"
                        alt="<?php the_title(); ?>" class="left" width="100px" height="65px"  /></a>
                    <?php } ?>
                    <div class="info">
                        <a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
                        <div class="meta">
                            [<?php the_time('j M Y') ?> | <?php comments_popup_link('No Comment', 'One Comment', '% Comments');?> | <?php if(function_exists('the_views')) { the_views(); } ?>]
                        </div>
                        <?php the_excerpt(); ?>
                    </div>
                </div>
            <?php endwhile; ?>
        	<?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) : ?>
       		<?php endif; ?>
        	</div>
        </div>
            
        <div id="sidebar-ads">
            <a href="http://www.outplaypoker.com"><img src="<?php echo get_option('home'); ?>/wp-content/themes/arthemia/images/banners/sidebar-banner.png" alt="Outplay Poker Store" width="300px" height="250px" /></a>
        </div>
        
        <div id="sidebar-bottom"> 
            <?php 	/* Widgetized sidebar, if you have the plugin installed. */ 					if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(4) ) : ?> 
            <?php endif; ?>	
        </div>  
    </div>
    
    PHP:
     
    Borduhh, Mar 13, 2011 IP
  3. MasterOfNone

    MasterOfNone Member

    Messages:
    15
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #3
    Try this code.

    
    <?php
    if ( is_home() ) {
        // This is a homepage
    } else {
        // This is not a homepage
    }
    ?>
    
    Code (markup):
    More conditionals tags.
    http://codex.wordpress.org/Category:Conditional_Tags


    hope that helps
     
    MasterOfNone, Mar 14, 2011 IP
  4. ayekaye01

    ayekaye01 Peon

    Messages:
    214
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    i think you need to have a home2.php or an index2.php then upload it.
     
    ayekaye01, Mar 16, 2011 IP