• Resolved mamulea

    (@mamulea)


    Hello. I am trying to detect in sidebar if the page displayed is the main page. However, both is_home() and is_front_page() return false, wether it is the main page or not. I have read a lot of codex and forum threads about this but nothing seems to work. Any idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • May try this just before your Conditional Tags

    wp_reset_query();
    Thread Starter mamulea

    (@mamulea)

    10x, it worked!

    I’m having the same problem but

    wp_reset_query();

    isn’t working for me. is_home fails to recognize this template ever since I added the category call below:

    query_posts(‘category_name=Music&posts_per_page=5’);

    Here is my home.php code

    <?php get_header(); ?>
    
    		<div id="container">
    			<div id="content">
    
    			<?php //The Query
    query_posts('category_name=Music&posts_per_page=5'); 
    
    			//The Loop
    			 while ( have_posts() ) : the_post(); ?>
    		<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
    
    			<div class="entry-meta">
    				<?php
    					printf( __( '<span class="meta-prep meta-prep-author">Posted on </span><a href="%1$s" title="%2$s" rel="bookmark"><span class="entry-date">%3$s</span></a> <span class="meta-sep"> by </span> <span class="author vcard"><a class="url fn n" href="%4$s" title="%5$s">%6$s</a></span>', 'twentyten' ),
    						get_permalink(),
    						esc_attr( get_the_time() ),
    						get_the_date(),
    						get_author_posts_url( get_the_author_meta( 'ID' ) ),
    						sprintf( esc_attr__( 'View all posts by %s', 'twentyten' ), get_the_author() ),
    						get_the_author()
    					);
    				?>
    			</div><!-- .entry-meta -->
    
    			<div class="entry-content">
    				<?php the_content( __( 'Continue&nbsp;reading&nbsp;<span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
    				<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    			</div><!-- .entry-content -->
    
    			<div class="entry-utility">
    				<span class="cat-links"><span class="entry-utility-prep entry-utility-prep-cat-links"><?php echo twentyten_cat_list(); ?></span></span>
    				<span class="meta-sep"> | </span>
    				<?php $tags_text = twentyten_tag_list(); ?>
    				<?php if ( ! empty( $tags_text ) ) : ?>
    				<span class="tag-links"><span class="entry-utility-prep entry-utility-prep-tag-links"><?php echo $tags_text; ?></span></span>
    				<span class="meta-sep"> | </span>
    				<?php endif; //$tags_text ?>
    				<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    				<?php edit_post_link( __( 'Edit', 'twentyten' ), "<span class=\"meta-sep\">|</span>\n\t\t\t\t\t\t<span class=\"edit-link\">", "</span>\n\t\t\t\t\t\n" ); ?>
    			</div><!-- #entry-utility -->
    		</div><!-- #post-<?php the_ID(); ?> -->
    
    		<?php comments_template( '', true ); ?>
    <?php endwhile; wp_reset_query();?>
    			</div><!-- #content -->
    		</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘is_home in sidebar’ is closed to new replies.