Conditional Statement to Query Posts in Header
-
Hi, I’m trying to use query_posts in my header file and make it conditional so it only displays on the home page.
Currently, this displays on all pages and pulls in the content of the page rather than the post with ID 68. When I remove the conditional statement, it grabs post ID 68 perfectly, except it’s not conditional to the home page only.
I’m unsure of how to use the “if is_home” conditional statement with query_posts. I’m trying to put this together based on what I learned in Codex but this is a bit more advanced than I can manage I think.
Thanks in advance for any help!
if ( is_home() ) { // The Query query_posts( 'p=68' ); } // The Loop while ( have_posts() ) : the_post(); echo '<div class="the_content" id="home-quote-container">'; echo '<div class="home-quote-img">'; the_post_thumbnail('home-quote-img'); echo '</div>'; echo '<div class="home-quote-text">'; echo '<div class="home-quote-content">'; the_content(); echo '</div>'; echo '<div class="home-quote-excerpt">'; the_excerpt(); echo '</div>'; echo '</div>'; echo '<div style="clear:both;"></div>'; echo '</div>'; endwhile; // Reset Query wp_reset_query();
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘Conditional Statement to Query Posts in Header’ is closed to new replies.