custom post types - Do not load the categories in Category.php

admin2025-06-03  5

I have a CPT and each post has categories and sub categories. When I enter the Category.php page this does not print any post.

    <?php  get_header(); ?>
<div class="row">
    <div class="col-12 float-left mt-3">
        <h1>Category <span><?php single_cat_title(); ?></span></h1>
    </div>
</div>
<div id="pro" class="row">
    <div class="col-12 col-lg-3 float-left">
    <?php
        get_sidebar();
    ?>
    </div>
    <div class="col-12 col-lg-9 float-left">
    <?php while(have_posts()): the_post();?>
    <?php the_title();?>
    <?php endwhile;?>
    </div>
    </div>
</div>
<?php  get_footer(); ?>

I have a CPT and each post has categories and sub categories. When I enter the Category.php page this does not print any post.

    <?php  get_header(); ?>
<div class="row">
    <div class="col-12 float-left mt-3">
        <h1>Category <span><?php single_cat_title(); ?></span></h1>
    </div>
</div>
<div id="pro" class="row">
    <div class="col-12 col-lg-3 float-left">
    <?php
        get_sidebar();
    ?>
    </div>
    <div class="col-12 col-lg-9 float-left">
    <?php while(have_posts()): the_post();?>
    <?php the_title();?>
    <?php endwhile;?>
    </div>
    </div>
</div>
<?php  get_footer(); ?>
Share Improve this question asked Feb 5, 2019 at 3:53 Marco MirelesMarco Mireles 31 bronze badge 2
  • Does the rest of this page load? If you add something like <h1>Hello!</h1> before the first line, do you see it when visiting that category page? – phatskat Commented Feb 5, 2019 at 5:49
  • 1 No, but i solved, it was something with the permalink. – Marco Mireles Commented Feb 6, 2019 at 22:42
Add a comment  | 

1 Answer 1

Reset to default 0

First of all the template is category.php (without a capital letter.

Second of all, you say you have a

Custom Post Type with categories

most likely you mean you have a

Custom Post Type with a Custom Taxonomy

In order to design a custom page template to show cpt from a custom taxonomy, you need to use name your template taxonomy.php. Please see the template hierarchy for more details.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748941866a315017.html

最新回复(0)