HotNews Pro 2.7 Plus侧边最新文章中排除分类

HotNews主题15315.1K阅读模式
摘要  HotNews Pro主题CMS首页最新文章已具备分类排除功能,那么如何为主题自带的最新文章小工具添加排除分类功能呢?   用下面代码替换主题newarticles.php模版...

HotNews Pro主题CMS首页最新文章已具备分类排除功能,那么如何为主题自带的最新文章小工具添加排除分类功能呢?万能的WP什么都可实现的。

用下面代码替换主题\includes\widget目录newarticles.php模版中所有内容即可。

  1. <div class="newarticles">
  2.     <h3>最新文章</h3>
  3.     <div class="box_r">
  4.         <ul>
  5.             <li>
  6.                 <?php query_posts('showposts=9&caller_get_posts=10&cat=-6,-8'); while ( have_posts() ) : the_post(); ?>
  7.                 <a href="<?php the_permalink(); ?>"><?php echo mb_strimwidth(get_the_title(), 0, 31, '');?></a>
  8.                 <?php endwhile; ?>
  9.             </li>
  10.         </ul>
  11.         <div class="clear"></div>
  12.     </div>
  13.     <div class="box-bottom">
  14.         <i class="lb"></i>
  15.         <i class="rb"></i>
  16.     </div>
  17. </div>

其中:数字9为显示的最新文章数量,数字10是排除10篇置顶文章,-6和-8为排除的分类ID,可自行修改。

另外,在正文及分类页面的侧边TAB菜单中,也存在最新文章,打开主题includes目录的tab.php模版,用:

  1. <?php query_posts('showposts=9&caller_get_posts=10&cat=-6,-8'); while ( have_posts() ) : the_post(); ?>
  2. <li><a href="<?php the_permalink(); ?>"><?php echo mb_strimwidth(get_the_title(), 0, 31, '');?></a></li>
  3. <?php endwhile; ?>

替换其中的:

  1. <?php $myposts = get_posts('numberposts=10&offset=0');foreach($myposts as $post) :?>
  2. <li><a href="<?php the_permalink(); ?>" rel="bookmark" title="详细阅读 <?php the_title_attribute(); ?>"><?php echo cut_str($post->post_title,33); ?></a></li>
  3. <?php endforeach; ?>

可修改的参数同上。

上面代码替换后,如有什么问题可以反馈给我。

PS:由于最近工作忙,很少有时间回复网友的问题,简单的可能会抽时间回答一下,稍微复杂一些的大家只能耐心等我有时间经过测试,得出比较准确的答案,再回复你,包括有DIY请求的童鞋。

本站文章大部分始于原创,用于个人学习记录,可能对您有所帮助,仅供参考!

weinxin
我的微信
版权声明
本站原创文章转载请注明文章出处及链接,谢谢合作!
 
  • HotNews主题
  • WordPress
WordPress › Error

Error establishing a Redis connection

To disable Redis, delete the object-cache.php file in the /wp-content/ directory.