咱們有時須要根據實際須要進行一些設置,好比wordpress調用指定分類除外的置頂文章,如何實現呢?隨ytkah一塊兒來看看吧,用以下代碼插入到須要調取的位置php
<div class="recommended-container"> <div class="title"><strong>RECOMMENDED</strong></div> <div class="box"> <ul> <?php $args = array( 'post_type' => 'post', 'showposts' => 3, // 'orderby' => 'rand', 'post__in' => get_option('sticky_posts'),//獲取置頂文章 'cat' => array(-36,-37,-38),//排除指定分類id ); $my_query = new WP_Query($args); if( $my_query->have_posts() ) { while ($my_query->have_posts()) : $my_query->the_post(); ?> <li> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail( array(88,88) ); ?> <strong><?php the_title();?></strong> </a> </li> <?php endwhile; wp_reset_query(); } ?> </ul> </div> </div>