在Avada的儿童主题中,更新您的类别。php,如果其there或elsecret使用该名称创建新文件,并添加以下代码:
<?php
$current_cat = get_queried_object();
echo \'Heading: \'.$current_cat->name;
$subcategories = get_categories(
array( \'parent\' => $current_cat->term_id )
);
if(!empty($subcategories)){
foreach($subcategories as $cat){
echo \'<br>\'.$cat->name.\'<br>\';
$cat_posts = get_posts( array(
\'posts_per_page\' => -1,
\'category\' => $cat->term_id
) );
if ( $cat_posts ) {
foreach ( $cat_posts as $post ) :
echo $post->post_title.\'<br>\';
endforeach;
}
}
}else{
$cat_posts = get_posts( array(
\'posts_per_page\' => -1,
\'category\' => $current_cat->term_id
) );
if ( $cat_posts ) {
foreach ( $cat_posts as $post ) :
echo $post->post_title.\'<br>\';
endforeach;
}
}
它会完全按照你的要求打印出来。
更新:要将帖子作为链接获取,我们可以添加如下标记:
随处更改:
echo $post->post_title.\'<br>\';
收件人:
echo \'<a href="\'.get_permalink().\'">\'.$post->post_title.\'</a><br>\';
它会将帖子作为链接。