feat: mutli-categories

This commit is contained in:
Kazhnuz 2023-03-12 16:15:46 +01:00
parent af058e2d8c
commit 365781adbc
3 changed files with 60 additions and 49 deletions

View file

@ -1,19 +1,33 @@
<nav class="navbar navbar-expand-lg navbar-dark bg-grey" id="navbar-category">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<?php
$parent_categories = get_categories( array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0
) );
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav nav-justified w-100">
foreach( $parent_categories as $parent_category ) {
?>
<li>
<span class="btn btn-navbar">
<?php echo $parent_category->name ?> <i class="fa fa-caret-down" aria-hidden="true"></i>
<ul class="card-menu">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
'orderby' => 'slug',
'order' => 'ASC',
'parent' => $parent_category->term_id
) );
foreach( $categories as $category ) {
echo '<li class="nav-item"><a class="nav-link" href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}?>
if ($category->slug != "chapters") {
echo '<li><a class="menu-element" href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}
}
?>
</ul>
</div>
</nav>
</span>
</li>
<?php
}
?>

View file

@ -5,24 +5,7 @@
<i class="fa fa-home" aria-hidden="true"></i><span class="sr-only">Accueil</span>
</a>
</li>
<li>
<span class="btn btn-navbar">
Catégories <i class="fa fa-caret-down" aria-hidden="true"></i>
<ul class="card-menu">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
) );
foreach( $categories as $category ) {
if ($category->slug != "blog" && $category->slug != "chapters") {
echo '<li><a class="menu-element" href="' . get_category_link($category->term_id) . '">' . $category->name . '</a></li>';
}
}?>
</ul>
</span>
</li>
<?php include(TEMPLATEPATH . '/components/navbar-category.php'); ?>
<?php
$listmenu = get_nav_menu_locations();
$menu = wp_get_nav_menu_items($listmenu['top-navbar']);

View file

@ -1,16 +1,30 @@
<?php
$parent_categories = get_categories( array(
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0
) );
foreach( $parent_categories as $parent_category ) {
?>
<div class="card card-primary">
<div class="card-header"><i class="fa fa-folder" aria-hidden="true"></i> Catégories</div>
<div class="card-header"><i class="fa fa-folder" aria-hidden="true"></i> <?php echo $parent_category->name ?></div>
<ul class="card-menu">
<?php
$categories = get_categories( array(
'orderby' => 'name',
'order' => 'ASC'
'orderby' => 'slug',
'order' => 'ASC',
'parent' => $parent_category->term_id
) );
foreach( $categories as $category ) {
if ($category->slug != "blog" && $category->slug != "chapters") {
if ($category->slug != "chapters") {
echo '<li><a class="menu-element" href="' . get_category_link($category->term_id) . '">' . $category->name . '<span class="menu-label label-secondary">'. $category->count . '</span></a></li>';
}
}?>
}
?>
</ul>
</div>
<?php
}
?>