I have registered a custom post type in functions.php like this:

function wpt_portfolio_posttype() {
  register_post_type( 'portfolio',
    array(
      'labels' => array(
        'name' => __( 'Portfolio' ),
        'singular_name' => __( 'Portfolio Posts' ),
        'add_new' => __( 'Add New Portfolio Post' ),
        'add_new_item' => __( 'Add New Portfolio Post' ),
        'edit_item' => __( 'Edit Portfolio Post' ),
        'new_item' => __( 'Add New Portfolio Post' ),
        'view_item' => __( 'View Portfolio Post' ),
        'search_items' => __( 'Search Portfolio Post' ),
        'not_found' => __( 'No Portfolio post found' ),
        'not_found_in_trash' => __( 'No Portfolio post found in trash' )
      ),
      'public' => true,
      'supports' => array( 'title', 'editor', 'thumbnail' ),
      'capability_type' => 'post',
      'rewrite' => array("slug" => "portfolio"), // Permalinks format
      'menu_position' => 4,
      'menu_icon' => 'dashicons-portfolio',
      'taxonomies'   => array( 'category' ),
      'has_archive' => true,
    )
  );
}

add_action( 'init', 'wpt_portfolio_posttype' );

And it works quite good. I can add new Portfolio Posts etc. But here is my problem: When I create a Portfolio Post, add them to a category (let’s say “Personal”) and add a new Menu Item to display all the “Personal” Posts Menu->Categories->Personal to the Menu, all Posts from my custom post type won’t be displayed. Does anyone know why?

Here’s my category.php

<?php

get_header(); ?> 

<div class="col-sm-9 col-lg-10">

  <?php 
  // Check if there are any posts to display
  if ( have_posts() ) : ?>

    <div id="content" class="row">

    <h1 class="archive-title">Category: <?php single_cat_title( '', false ); ?></h1>

    <?php
    // Display optional category description
     if ( category_description() ) : ?>
    <div class="archive-meta"><?php echo category_description(); ?></div>
    <?php endif; ?>

    <?php

    // The Loop
    while ( have_posts() ) : the_post(); ?>
      <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>

      <div class="entry">
      <?php the_content(); ?>

      </div>

    <?php endwhile; 

  else: ?>
    <p>Sorry, no posts matched your criteria.</p>

    </div>

<?php endif; ?>

</div>

<?php get_footer(); ?>

I also tried to register a Custom Category (and reverted it) but I have no luck to get the Posts from my Custom Post Type. Can someone help me out?

Thank you in advance!

Read more here: Custom Post Type won’t show in Category Page


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: