除了假定在各个类别中显示员额计数的部分以外, 以下代码可以正确显示。使用正确的语法将是什么?谢谢!
<ul class="cat-menu list-group">
<?php $category_ids = get_all_category_ids();
$args = array(
'orderby' => 'slug', 'parent' => 0
);
$categories = get_categories( $args );
foreach ( $categories as $category ) {
echo '<li class="list-group-item d-flex align-items-center"><a href="' . get_category_link( $category->term_id ) . '" rel="bookmark"><i class="fa fa-chevron-right" aria-hidden="true"></i>' . $category->name . '<span>' . $the_query->found_posts . '</span></a></li>';
}
?>
#1
尝试这个-
<ul class="cat-menu list-group">
<?php
$args = array(
'orderby' => 'slug', 'parent' => 0
);
$categories = get_categories( $args );
foreach( $categories as $category ){
echo '<li class="list-group-item d-flex align-items-center"><a href="' . get_category_link( $category->term_id ) . '" rel="bookmark"><i class="fa fa-chevron-right" aria-hidden="true"></i>' . $category->name . '<span>' . $category->category_count . '</span></a></li>';
}
?>
</ul>
#2
非常感谢@ Arif-Khan。
这是波斯网站的简单更新。
<div class="card card-body pb-0">
<div class="single-post">
<p class="font-bold dark-grey-text text-center spacing grey lighten-4 py-2 mb-4">
<strong>دسته بندی</strong>
</p>
<ul class="cat-menu list-group my-4">
<?php
$args = array(
'orderby' => 'slug', 'parent' => 0
);
$categories = get_categories( $args );
foreach( $categories as $category ){
echo '<li class="list-group-item d-flex justify-content-between align-items-center"><a href="' . get_category_link( $category->term_id ) . '">
<i class="fas fa-chevron-left blue-text" aria-hidden="true"></i><p class="blue-grey-text mb-0 pr-1 d-inline-block">
' . $category->name . '</p></a>
<span class="badge badge-pill blue-grey font-small">' . $category->category_count . '</span></li>';
}
?>
</ul>
</div>
</div>
评论前必须登录!
注册