News Ticker not working on wordpress pages
-
13-12-2019 - |
题
Jquery ticker working on my site home page perfectly , but not working on pages . I dont know why.
On pages this ticker not is showing posts, it shows only the page list.
Here is code of TICKER on header
<div class="fl" id="hotnews">
<ul id="shreshth_news" class="shr_news">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li><span class="heading"><a href="<?php the_permalink(); ?>"><?php the_title(); ?> </a> </span><span class="info"></span></li>
<?php endwhile; ?>
</ul></div>
This ticker working smoothly on single.php index.php etc
解决方案
Add this instead of above code
<div class="fl" id="hotnews">
<ul id="js-news" class="js-hidden">
<?php $the_query = new WP_Query('showposts=5&orderby=post_date&order=desc');
while ($the_query->have_posts()) : $the_query->the_post(); ?>
<li><span class="heading"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> </span><span class="info"></span></li>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</ul></div>
不隶属于 StackOverflow