$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>custom post types - Do not load the categories in Category.php|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

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

matteradmin10PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far