Pagination does not work with query_posts()
the_posts_pagination works with the global $wp_query, so your second method will not work. query_posts modifies the main query but the arguments passed will overwrite any existing values, so all values needed for pagination are lost when you set cat=5. But you can preserve the existing values by modifying the global query string. A more efficient … Read more