xxxxxxxxxx
$espbc = get_sub_field('add_posts_by_category');
$defaults_param = array(
//'numberposts' => -1,
'post_type' => 'post',
'category' => $espbc,
'posts_per_page' => 6,
'suppress_filters' => false
);
$catPost = get_posts($defaults_param);
xxxxxxxxxx
$defaults_param = array(
'numberposts' => -1,
'post_type' => 'post',
'category' => 40 ,
'suppress_filters' => false
);
$get_featured_post = get_posts($defaults_param);
xxxxxxxxxx
<?php
$args = array(
'category_name' => 'your_category_slug',
'posts_per_page' => -1, // Use -1 to retrieve all posts
);
$posts = new WP_Query($args);
if ($posts->have_posts()) {
while ($posts->have_posts()) {
$posts->the_post();
// Display post information as desired
the_title(); // Example: renders the post title
the_content(); // Example: renders the post content
}
} else {
// No posts found
}
// Restore original post data
wp_reset_postdata();
?>
xxxxxxxxxx
<?php query_posts('category_name=CATEGORYNAME&showposts=5');
while (have_posts()) : the_post(); ?>
the_title(); // To display the title of all posts that have category name selected
the_content(); // To display the content of all posts that have category name selected
<?php endwhile; ?>
xxxxxxxxxx
$args = [
'post_type' => 'product',
'tax_query' => [
[
'taxonomy' => 'my_custom_taxonomy',
'terms' => 7,
'include_children' => false // Remove if you need posts from term 7 child terms
],
],
// Rest of your arguments
];