获取当前分类下文章
方法一: 1 2 3 4 5 6 7 8 <?php $cat_id=the_catego…
方法一:
| 
 1 
2 
3 
4 
5 
6 
7 
8 
 | 
 <?php 
       $cat_id=the_category_ID(false);
 
       $fenlei=‘posts_per_page=10&caller_get_posts=1&cat=’.$cat_id.‘&orderby=rand’;
 
        query_posts($fenlei);
 
   ?>
 
<?php while (have_posts()) : the_post(); ?>
 
<li><a href=“<?php the_permalink(); ?>“ title=“<?php echo get_the_title(); ?>“ class=“title” target=“_blank”> <?php echo get_the_title(); ?></a> </li>
 
<?php endwhile;?>
 
 | 
方法二:
 
| 
 1 
2 
3 
4 
5 
6 
7 
8 
 | 
 <?php 
	   $num = rand(1, 6);
 
	   //$num = 1;
 
		$cat_ID = get_query_var(‘cat’);
 
		query_posts( array( ‘cat’ => $cat_ID,‘posts_per_page’ => 6, ‘paged’ => get_query_var(‘paged’) ) );
 
		if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
 
        <li><a href=“<?php the_permalink(); ?>“ title=“<?php echo get_the_title(); ?>“ class=“title” target=“_blank”> <?php echo get_the_title(); ?></a> </li>
 
<?php endwhile; wp_reset_query(); ?>
 
 | 
类别:WordPress开发、 
		本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。





评论功能已经关闭!