In my file category.php
I have a layout where I have a side menu where the subcategorias
of the categoria
current and a <section></section>
should be displayed where the posts of the current categoria
and subcategoria
, to generate the menu with the subcategorias
of categoria
current I did:
$categories = get_categories('child_of='.get_the_category()[0]->term_id);
<nav class="panel">
<?php foreach($categories as $category): ?>
<a href="<?= get_category_link($category->term_id); ?>" class="panel-block">
<?= $category->name; ?>
<span class="icon"><i class="fa fa-angle-right fa-fw"></i></span>
</a>
<?php endforeach; ?>
</nav>
In section
I did:
<?php query_posts('posts_per_page=-1&cat='.get_the_category()[0]->term_id); ?>
<?php if (have_posts()): while(have_posts()): the_post(); ?>
<article class="column is-half">
<div class="price-label">
<div class="price-title">
<h1 class="title is-6">0001. <?php the_title(); ?></h1>
<h2 class="subtitle is-6">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Perferendis.</h2>
</div>
<div class="price-tag has-text-right">
<p><span class="size">P</span> <small>R$</small> 21.90</p>
<p><span class="size">M</span> <small>R$</small> 25.90</p>
<p><span class="size">G</span> <small>R$</small> 35.90</p>
</div>
</div>
</article>
<?php endwhile; endif; ?>
I can not get section
to always get the posts of the current page being categoria
or subcategoria
, I can only get the categorial
current using get_the_category()[0]->term_id
, and I do not know how to get the% posts from current subcategoria
, how can I make posts
to be displayed according to current categoria
or subcategoria
?