PHP Displaying the Number of Posts in an Archive Page with PHP

Learn how to use PHP to show the number of posts in an archive page. Also, find out how to fetch the number of posts for any term using its identifier.

<?php
$term = get_queried_object();
$term->count;

$term = get_term_by('id', 1, 'category');
if (!empty($term)) {
    echo $term->count;
}
?>