Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Giorgia Makris
Giorgia Makris
3,377 Points

The Category Template: My categories don't appear at all

I am currently in the design a wordpress theme section and for some reason my categories do not show up at all on my page. I have posts that I assigned to specific categories so they are in my dashboard but do not appear when I view my page. Any ideas as to why this is?

6 Answers

Giorgia Makris
Giorgia Makris
3,377 Points

Thank you for your replies, I found out it was an issue in the content-post.php file. Fixed now!

Zac Gordon
Zac Gordon
Treehouse Guest Teacher

Great! Glad to hear you got it resolved :)

Matt Campbell
Matt Campbell
9,767 Points

Have you got any code to share with us?

Giorgia Makris
Giorgia Makris
3,377 Points

This is all that I would know to show you, I'm in the middle of a lesson but in the video that I'm on (The Category Template) everything seems to appear correctly.

This is what I have in category.php:

```<?php get_header(); ?>

<div class="grid_12 omega clearfix">

<h1>Category: <?php single_cat_title(); ?></h1>

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

        <?php get_template_part( 'content', 'post' ); ?>



<?php endwhile; else: ?>

    <p>There are no posts or pages here.</p>


<?php endif; ?> 

</div>

<?php get_footer(); ?>```

not sure if it is a problem in another page or what? pretty lost here

Giorgia Makris
Giorgia Makris
3,377 Points

^^^ that didn't come out right for some reason

<?php get_header(); ?>


<div class="grid_12 omega clearfix">

<h1>Category: <?php single_cat_title(); ?></h1>

    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <?php get_template_part( 'content', 'post' ); ?>



    <?php endwhile; else: ?>

        <p>There are no posts or pages here.</p>


    <?php endif; ?> 

</div>

<?php get_footer(); ?>
Matt Campbell
Matt Campbell
9,767 Points

There's two options:

1) You run a loop that asks for a specific category's posts or an array of categories. 2) Which is what I think you're doing, you need to put a link in a menu somewhere to that category.

If you look at http://ultimategamingparadise.com you'll see under news & reviews in the menu, lots of links. They're all selected from categories in menus in the admin area. Then WP template hierarchy looks for my category.php file to seek instruction on how to render the data. If you've got multiple post types, it can start to get tricky but that's the basic prinicpal. You're meant to use a category-{post-type} file for each post type but I've found a way to get around that, and I have no idea why it works. Something to do with WooCommerce. Zac Gordon would probably know.

I think that answers your question, at least, I hope it does and gets you on your way! :)

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

How is it that you are accessing the category page on the front-end of the site? Even just a basic loop should display your category posts.