I don’t know how to explain my problem but I like to echo the specific category/ slug inside the specified section (sorting off by categories). I don’t know which WordPress function should be use? is it get_category or get_post?
so far I have this code to echo all the categories in one section:
<?php
$args = array(
'post_type' => 'allproducts',
'posts_per_page' => 9,
);
$posts = get_posts( $args );
foreach ( $posts as $post ):
setup_postdata( $post );
?>
basically my goal is to get all the post from specific category:
I have these list of categories with specific slugs and ID:
Category Name | Slug | ID
Shoes | cat01| 2
Pants | cat02| 3
Tops | cat03| 4
2
Answers
I figure it out. here's my code:
array (1) --> is the id of my category
closed it with this code