Skip to content
Drempd Logo
  • home
  • portfolio
  • web design journal
  • blog
    • adventure
    • san diego
    • projects
    • website design
    • code notes
  • contact
Blog Web Dev

WordPress – Category Page Not Showing Posts With Custom Post Type

By Forrest Smith - Drempd.com

I had created a post type for news articles. Unfortunately, when categorizing the pages, and trying to view the category from the front end, those posts weren't appearing.   Apparently that doesn't work for cusotm post types by default. To get them to show, add this to the functions.php file:

function namespace_add_custom_types( $query ) {
   if( (is_category() || is_tag()) && $query->is_archive() && empty( $query->query_vars['suppress_filters'] ) ) {
      $query->set( 'post_type', array(
       'post', 'news'
      ));
   }
}
add_action( 'pre_get_posts', 'namespace_add_custom_types' );

Posted on May 25, 2022August 26, 2022 in Web Dev

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

I love to create and explore. Whether building a website or app, taking a long walk through the mountains, or playing with a random idea, I've found that there will never be enough time to experience it all. But that won't stop me from trying.

Web Design & Development

  • Portfolio
  • San Diego Website Design
  • Custom Web Design
  • Responsive Web Design
  • Website Maintenance
  • Freelance Web Designer
  • Web Design Posts
  • Website Checklist

Projects

  • Zindash
  • Opti
  • Saphire CSS
  • Ergo Blocks

Blog

  • Adventure
  • San Diego
  • Projects
  • Website Design
  • Arch & Urban
  • Technology
  • Code Notes

About

  • Bluesky
  • Resume
  • Contact
drempd | san diego, ca
© 2026 Drempd All rights reserved.