我有一个 wordpress 网站,我想在类别中显示帖子标题列表。像
第一类 帖子 1 帖子 2 第 2 类 帖子 1 帖子 2 帖子 3 第 3 类 帖子 1 帖子 2
$show_count = 0;
$pad_counts = 0;
$分层= 1;
$taxonomy = '过滤器';
$标题=真;
$描述=真;
$args = 数组(
'show_count' => $show_count,
'pad_counts' => $pad_counts,
'分层' => $分层,
'分类法' => $分类法,
'use_desc_for_title' => $描述,
'title_li' => $title
);
$categories=get_categories($args);
foreach($categories as $category) {
echo '<p>Category: <a href="' .get_category_link( $category->term_id ) . '" title="' . sprintf( __( "查看 %s 中的所有帖子" ), $category->name ) '"'。'>' 。$category->name.'</a> </p>';
//显示帖子
$cat_new = $category->term_id;
$post_args = array('numberposts' => -1, 'category' => $cat_new, 'caller_get_posts' => 0);
$myposts = get_posts($post_args);
foreach( $myposts as $post ) : setup_postdata($post); ?>
echo '<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?>';
结束;}
上面的代码只是显示一个类别列表,而不是它下面的帖子标题。
我很困惑,我已经阅读了很多博客并为此发帖,但仍未完成。任何帮助将不胜感激。提前致谢。