使用“分类文章”小部件自定义文章排序顺序
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用“分类文章”小部件自定义文章排序顺序相关的知识,希望对你有一定的参考价值。
Edit widget or display current category in sidebar.php
// Get array of post info. $cat_posts = new WP_Query("showposts=" . $instance["num"] . "&cat=" . $instance["cat"] . '&orderby=date&order=asc'); The Category Posts Widget is very good for showing a certain # of posts in a particular category using a widget that displays on every page. However, if you only want to show the posts for the current category in the sidebar, then add this code to your sidebar.php file: <?php $sidebar_related_query = new WP_Query('cat=' . $sidebar_cat_id . '&showposts=5&offset=0&orderby=post_date&order=desc'); while ($sidebar_related_query->have_posts()) : $sidebar_related_query->the_post(); $do_not_duplicate = $post->ID; ?> <div id=â€post-<?php the_ID(); ?>"> <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a> </div> <?php endwhile; ?>
以上是关于使用“分类文章”小部件自定义文章排序顺序的主要内容,如果未能解决你的问题,请参考以下文章