WordPress自带的widget侧边栏小工具虽然可以很轻松的调用最新文章,热门文章,随机文章。但使用侧边栏将会影响我们自定义的侧边栏效果。很多用wordpress的博客朋友都会使用其他插件来实现调用,例如中文工具箱。下面将介绍一下不用插件调用这三种类型文章的方法。
调用最新文章:
- have_posts()) : $post_query->the_post(); ? ? $do_not_duplicate = $post->ID; ?> ? ?
- ? ? ? ?
调用热门文章:
- '', ? ? ? ? 'post_status' => 'publish', // 只选公开的文章. ? ? ? ? 'post__not_in' => array($post->ID),//排除当前文章 ? ? ? ? 'caller_get_posts' => 1, // 排除置頂文章. ? ? ? ? 'orderby' => 'comment_count', // 依評論數排序. ? ? ? ? 'posts_per_page' => $post_num ? ? ); ? ? $query_posts = new WP_Query(); ? ? $query_posts->query($args); ? ? while( $query_posts->have_posts() ) { ? ? ? ? $query_posts->the_post(); ?> ? ?
- ? ? ? ?
调用随机文章:
- ID; ? ? $args = array( 'orderby' => 'rand', 'post__not_in' => array($post->ID), 'showposts' => 10); ? ? $query_posts = new WP_Query(); ? ? $query_posts->query($args); ?> have_posts()) : ? ? ? ? $query_posts->the_post(); ?> ? ?
- ? ? ? ?