I'm new to WordPress and trying my best but I can't seem to load any category posts...

Just to be clear - why I mean is that when a page publishes a breacrumb 'category' tag, if that tag is clicked then nothing loads.

I understand that the WordPress hierarchy works like this:

category-slug.php → category-id.php → category.php → archive.php → index.php

I thought that I would just need to loop the posts within that category but nothing loads...

Here is the code I have been trying without success:

 * Template Name: Category

if (!defined('ABSPATH'))
    exit; // Exit if accessed directly

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

        <div class="container">
          <div class="row">
            <div class="col-xs-12  paddingtop">

        <?php the_content(); ?>

    <?php endwhile; ?>
<?php endif; ?>


        <?php get_footer(); ?>

Do I need to change something in the settings of WordPress - what is it that I might be missing?

Perhaps functions.php needs a command?

Thanks for all direction

  • where you create a this file? your code is working fine – Jignesh Patel Aug 24 '17 at 3:59
  • I saved this file as category.php but it shows no other posts of that category when it clicked – henry Aug 24 '17 at 4:00
  • category.php file is override archive.php file so which category open this category post can be display not all – Jignesh Patel Aug 24 '17 at 4:04
  • So I should just use the same code in archive.php and that will publish (loop) all posts in that category? (Thanks for your help) – henry Aug 24 '17 at 4:07
  • you can change in archive.php then it's change all listing pages – Jignesh Patel Aug 24 '17 at 4:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.