【发布时间】:2016-06-04 05:24:17
【问题描述】:
我已显示“主页”类别帖子主页。点击“阅读全文” 第一篇文章。 它正在显示第一篇文章的所有详细信息。
现在我想用“Readmore”显示“第一篇文章”下面的所有帖子。
这是我的代码,它显示了一些其他类别的帖子。
<?php
$categories = get_the_category();
$catID = the_category_ID($echo=false); //Current selected category ID
$catPost = get_posts('cat=$catID&posts_per_page=3');
foreach ($catPost as $post) : setup_postdata($post);
?>
<h1><a><?php the_title(); ?></a></h1>
<?php the_excerpt(); ?>
<p class="postinfo">Written by: <?php the_author_posts_link(); ?>
Posted on: <?php the_time('F j, Y'); ?> at <?php the_time('g:i a'); ?>
Categories: <?php the_category(', '); ?></p>
<hr />
<?php endforeach;?>
帖子页面
【问题讨论】:
-
您的意思是按类别或当前类别显示所有帖子。
-
没有。只想显示选定的类别帖子。并非所有类别
-
是的。当前类别帖子
-
使用 get_posts('category_name=CATEGORYNAME&posts_per_page=5');或使用 wp_query 像 $getpost = new WP_Query('category_name=my_second_category', 'posts_per_page'=>3); ?>
-
我如何动态使用它?
标签: wordpress