怎么让WordPress首页显示文章摘要
这个我在去年有发布了一篇关于“几招搞定wordpress自由获取指定分类中的日志”的文章,参考地址:http://jokerliang.com/get-posts-from-specific-category-in-wordpress.html至于您说的第一篇显示摘要或显示第一张图片等,可以通过增加记数变量来判断,比如$i = 1;while ( have_posts() ) : the_post();echo '';the_title();echo '';if ( 1 == $i ){the_excerpt();}else {the_content();}$i++;endwhile;$i即为记数变量。
记得有很多人有提过想在第一篇日志或第三篇日志后面显示广告,其实就可以用这个实现。
wordpress怎么调用指定的一篇文章?
<?php$post_num = 10; // 设置调用条数$args = array('post_password' => ”,'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(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?><?php } wp_reset_query();?>以上是热门文章的调用代码,放在侧边栏试试就知道了
转载请注明出处51数据库 » wordpress文章摘要调用