嗨基本上我有一个页面模板。喜欢目录。 我不想要插件,因为我仍然想控制代码。
我只想问这是否可能?
==>目录页面(在6月号类别下)
然后打印特定类别下的所有子类别信息。喜欢这种格式:
=>子类别标题
then Posts Under (this) Subcategory
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
=>子类别2标题
then Posts Under (this) Subcategory
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
=>子类别3标题
then Posts Under (this) Subcategory
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
-> Post Title including Permalink
-> Post Excerpt
依旧......
我只是想知道wordpress是否有这种方法在特定的帖子类别下提取子类别..如何正确地在模板中显示它,就像我将为下一个问题创建另一个表内容它将自动打印所有子类别信息。请帮帮我。
由于
答案 0 :(得分:0)
试试这个......未经测试
<?php
$args = array(
'type' => 'post',
'child_of' => 0,
'parent' => '1', //Only get child categories
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 1,
'taxonomy' => 'category',
'pad_counts' => false
);
$categoryList = get_categories($args);
if(!empty($categoryList)){
foreach($categoryList as $category){
$postArgs = array(
'cat' => $category->id,
'post_type' => 'post' //Use other options as needed
);
query_posts($postArgs);
while ( have_posts() ) : the_post();
echo get_the_title();
echo get_permalink();
echo get_the_excerpt();
endwhile;
}
}
?>