Categories with only one post (3 posts)

  1. Igloomason
    Posted 5 years ago #

    My Gallery child theme has a dropdown categories menu which I like. When a category (or sub-category) is clicked, all the thumbs of posts within that category are displayed. However, when a category with only one post is clicked, it too is displayed as a thumb. I'm attempting to re-code the category template so that a page with only one post defaults to the single post template. I'm unfamiliar with what function would "count" the # of posts within that category. Something like this in the categories template?:

    <?php $cat=get_post($count);
    if (1==$cat)
    <!-- doing something with just one post -->
    <!-- default template with multiple posts -->

  2. Michael
    Forum Moderator
    Posted 5 years ago #

    $cat = $wp_query->post_count;

  3. Igloomason
    Posted 5 years ago #

    thanks alchymyth. that did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic