1
I’m creating the page Category.php and using a Custom Post Type called Father. Within that post type has some categories: 1, 2, 3, 4 etc. What I wanted was to enter the page category 4, showed only the posts of this category, but is showing all the posts that Post Type.
The loop that I’m using is this:
$args = array(
'post_type' => 'pai',
);
$loop = new WP_Query($args);
if ( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
<p>Existe Posts</p>
endwhile;
else:
<p>Não Existe Posts...</p>
endif;
wp_reset_postdata();
So I don’t understand
– Anderson Henrique
Let me try to explain to you what I need, on each page of the categories ex: site.com/cat/2 I need you to show only the posts of this category and not all, which is what’s happening with this loop I showed you.
– user117052
So, the answer I said worked... You put the category you want for example category 4 and there will be shown posts category 4
– Anderson Henrique
Yes, but on all pages will show posts of category 4.
– user117052
Have you tried filtering the data on
WP_Query
https://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters ?– Valdeir Psr
It doesn’t work :( , Will I need to make a file category-1.php for each of the categories? I wanted to do everything in the file Category.php
– user117052
If you will put only post for such category, da para você fazer relação entre elas
– Anderson Henrique
And how I do it?
– user117052