Answer the question
In order to leave comments, you need to log in
How to display the names of subcategories of a certain category, Wordpress?
Good evening!
Made a portfolio with filtering based on this article.
<div class="container content">
<div class="row row-margin">
<?php $args = array(
'parent' => 15,
'hide_empty' => 1,
'number' => '0',
'taxonomy' => 'category',
'pad_counts' => true );
$catlist = get_categories($args);
?>
<ul id="filters" class="clearfix">
<li><span class="filter active" data-filter="portrait wedding">all</span></li>
<?php
foreach ($catlist as $categories_item) {
echo "<li><span class=\"filter\" data-filter=\"$categories_item->cat_name\">" . $categories_item->cat_name . "</li>";
}
?>
</ul>
<div id="portfoliolist">
<?php
$query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => -1,
) );
?>
<?php
while ($query->have_posts()) :
$query->the_post();
?>
<?php $category = get_the_category(); ?>
<div class="col-lg-3 col-md-4 col-sm-6 col-xm-12 portfolio <?php echo $category[0]->cat_name; ?>" data-cat="<?php echo $category[0]->cat_name; ?>">
<div class="block-active">
<?php the_post_thumbnail('thumbnail'); ?>
</div><!--/block-active-->
</div><!--/col-->
<?php endwhile; ?>
</div><!--portfoliolist-->
</div><!--/row-->
</div><!--/container-->
Answer the question
In order to leave comments, you need to log in
It is more logical to make a custom post type "Portfolio", for it the taxonomy "Portfolio Categories" and display / filter by these categories.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question