我正在使用一个在每个页面上都有一个滑块的wordpress网站(但只有当我没有将网站设置为使用静态页面而不是我的帖子列表时在主页上) - 仍然和我在一起?切换到主页分页滑块上的静态内容
当主页(例如www.mysite.com
)在主页上显示我的数据库中的帖子列表时,滑块工作正常,但是当我将主页更改为使用页面中的静态内容时,已创建,滑块消失。
下面的代码:
<?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(); ?>
所以,现在我看到,在<div id="featured">
(这是滑块),$wp_query
被保存在$tmp_query
,然后在该网页的主要内容后重新使用。 因为我在主页上设置了静态内容,所以滑块不会显示在我网站的任何页面上。
我想要做的是在我的网站的每个页面上显示滑块,而不管该页面的内容是后置类型还是页面类型。 任何人都可以解释为什么页面类型的内容隐藏滑块(我能想到的是,if (have_posts()) :
返回false),并建议修复?
在此先感谢!