• Hello,

    let’s assume I have one main-category called “Miscellaneous” and some sub-categories. There are no articles at all, yet.

    Accessing exaple.com/category/miscellaneous/ leads to “Nothing Found”.

    How can I achieve that it lists the sub-categories instead?

    Kind regards
    Hugo

Viewing 4 replies - 1 through 4 (of 4 total)
  • in category.php, where the ‘nothing found’ text is (that is the ‘else :’ part of the ‘if(have_posts()) :’ conditional statement), add something like:

    <?php $subcats = wp_list_categories('echo=0&child_of=' . get_query_var('cat'));
    if($subcats) { ?>
    <ul>
    <?php echo $subcats; ?>
    </ul>
    <?php } else { echo 'nothing found'; } ?>

    details depend on the category.php template file of the theme.

    Thread Starter h-u-g-o

    (@h-u-g-o)

    Thank you very much!

    Is this going to work with TwentyTen?

    you need to find the corresponding area in loop.php, and probably make it conditional on is_category()

    it is this section you need to rework (near the beginning of loop.php):

    <div class="entry-content">
    			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyten' ); ?></p>
    			<?php get_search_form(); ?>
    		</div><!-- .entry-content -->
    Thread Starter h-u-g-o

    (@h-u-g-o)

    Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘List sub-categories instead of stating "Nothing Found"’ is closed to new replies.