Get all posts from a category.
<?php
$postslist = get_posts(array(
'category' => 1,
'posts_per_page' => -1,
));
if ($postslist) {
echo '<ul>';
foreach ($postslist as $post) {
printf(
'<li><a href="%s">%s</a></li>',
esc_url(get_permalink()),
esc_html(get_the_title())
);
}
echo '</ul>';
wp_reset_postdata();
}
?>
<?php
/*
$posts_array = get_posts(array(
'posts_per_page' => 5,
'offset' => 0,
'category' => '',
'category_name' => '',
'orderby' => 'post_date',
'order' => 'DESC',
'include' => '',
'exclude' => '',
'meta_key' => '',
'meta_value' => '',
'post_type' => 'post',
'post_mime_type' => '',
'post_parent' => '',
'post_status' => 'publish',
'suppress_filters' => true,
));
*/
?>
template.php