muban大师 发表于 2015-9-12 09:56:25

WordPress调用指定分类下的文章


       
          $args=array(
                'cat' => 1,   // 分类ID
                'posts_per_page' => 10] // 显示篇数
          );
          query_posts($args);
          if(have_posts()) : while (have_posts()) : the_post();
        ?>
          [*,
                 //标题
                
                
                      echo $description = get_the_excerpt(); //文章编辑中的摘要
                    }else {
                      echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content))] 0] 170]"……"); //文章编辑中若无摘要,自定截取文章内容字数做为摘要
                    } ?>
                
          
       
       
页: [1]
查看完整版本: WordPress调用指定分类下的文章