WordPress.org

Ready to get started?Download WordPress

Forums

Categories with only one post (3 posts)

  1. Igloomason
    Member
    Posted 3 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 -->
    else
    <!-- default template with multiple posts -->

  2. alchymyth
    Forum Moderator
    Posted 3 years ago #

    try:
    $cat = $wp_query->post_count;

  3. Igloomason
    Member
    Posted 3 years ago #

    thanks alchymyth. that did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic