You are already passing category in $args
. so not need to use get_categories()
. You can use below code.
$args = array(
'cat' => 5,
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
);
$custom_loop = new WP_Query($args);
if ($custom_loop->have_posts()) {
echo "<ul>";
while ($custom_loop->have_posts()) {
$custom_loop->the_post();
echo '<li><a href="' . get_permalink() . '">' . get_the_title() . '</a></li>';
}
echo "</ul>";
}
wp_reset_query();