I'm working on a wordpress website that has a slider on every page (but only when I haven't set the site to use a static page rather than a listing of my posts on the home page) - still with me?
When the home page (eg. www.mysite.com) has a list of the posts in my database displayed on the home page, the slider works fine, but when I change the home page to use static content from a Page that I've created, the slider disappears.
Here's the code:
<?php get_header(); ?>
<!-- begin featured-posts -->
<div class="break"></div>
<!-- begin featured -->
<div id="featured">
<?php
$tmp_query = $wp_query;
query_posts('showposts=3&cat=' . get_cat_ID(dp_settings('featured')));
if (have_posts()) :
while (have_posts()) : the_post();
?>
<!-- begin post -->
<div class="content">
<a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'alt="' . $post->post_title . '"'); ?></a>
<div class="title">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
</div>
<p><?php echo dp_clean($post->post_content, 250); ?> <br /><br /> [<a class="readmore" href="#">Read More</a>]</p>
<div class="break"></div>
</div>
<!-- end post -->
<?php endwhile; endif; ?>
</div>
<!-- end featured -->
<!-- BEGIN content -->
<div id="content">
<?php
$wp_query = $tmp_query;
if (have_posts()) :
while (have_posts()) : the_post();
?>
<!-- begin post -->
<div class="post">
<a href="<?php the_permalink(); ?>"><?php dp_attachment_image($post->ID, 'thumbnail', 'alt="' . $post->post_title . '"'); ?></a>
<h1><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h1>
<p><?php echo dp_clean($post->post_content, 350); ?><br /><br />[<a class="readmore" href="#">Read More</a>]</p>
</div>
<!-- end post -->
<div class="break"></div>
<?php endwhile; ?>
<div class="postnav">
<?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?>
</div>
<?php else : ?>
<div class="notfound">
<h2>Not Found</h2>
<p>Sorry, but you are looking for something that is not here.</p>
</div>
<?php endif; ?>
</div>
<!-- END content -->
<?php get_sidebar(); get_footer(); ?>
So now I see that in <div id="featured"> (this is the slider), $wp_query is being saved in $tmp_query, and then reused later on the main content for the page.
It doesn't make sense to me that the slider wouldn't display on any pages in my site just because I've set static content on the home page.
What I'd like to do is display the slider on every page in my site regardless of whether or not the content for that page is post-type or page-type.
Can anyone explain why the page-type content is hiding the slider (all I can think is that if (have_posts()) : is returning false) and suggest a fix?
Thanks in advance!