I thought WordPress was supposed to do all the heavy lifting as far
as filtering by categories, tags, authors, etc.
It does. Which is why you shouldn’t have done this:
$category = get_category( get_query_var( 'cat' ) );
$cat_id = $category->cat_ID;
$loop = new WP_Query( array( 'cat' => $cat_id ) );
In the main template files you shouldn’t be doing your own queries. Use the main loop:
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<!-- etc. -->
<?php endwhile; ?>
<?Php endif; ?>
The purpose if archive.php is to allow you to have a different template for archives. Not to manually query different posts. The only difference should be the HTML markup around the content.
Related Posts:
- Filtering a custom post type by custom taxonomy in archive template
- Why are posts from custom post type not displayed in “category” archive?
- Displaying category archive of custom post types
- Custom Post Type Archive Page: Set Posts Per Page, Paginate
- Archive page…limiting posts per page
- how do I group content in magazine-style ‘issues’?
- Regex problem in an add_rewrite_rule
- How to show related posts by category or custom post type?
- Query Custom Post by Category
- get_categories for custom post type and filter by custom taxonomy (brand) and list child categories of a defined category
- Category page only displaying the posts from a custom type
- How to list custom post types?
- custom taxonomy archive by year
- CPT Archive with core Category
- Custom Post Type Archive Page Filtering
- Show a Category X’s custom post type on Category X archive page?
- Custom post type, organized by categories
- WP Query with categories only shows one post and ignores the category
- The loop seems stuck to a single (now deleted) post
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Tag page only display 10 posts
- Archieve.php not loading for custom post type
- multiple custom post type on category page
- get_terms() parent, child and grandchild
- Use post in multiple places on a page with multiple posts
- Archive Template being used instead of Category Template for Custom Post Type
- pre_get_posts works in post type archive but not in single post
- Menu’s breaking, now showing all page links on site
- CPT archive page – show one post from each taxonomy term
- Advanced archive url structure (category, tag and date)
- How can I increase the post count for custom post types only?
- Show the categories the current post has
- Display all Categories except ones with a specific parent
- Pagination for a cpt filtered with a category
- Adding Custom Post Types to category/tag/author archives breaks header content
- Custom category taxonomy – archive page not showing up
- Excluding category from loop not working
- Custom post types not displaying per category
- Only show current category post
- How can I generate a list of post-type specific categories?
- Custom Post Type + Category archive
- Custom Post type archives / categories give 404
- How to query all custom posts of a certain type and checking what category they have
- archive.php can’t find categorized posts
- How can I set up the URL for a category archive for a custom post type?
- Categories in custom post types
- Categories and page filtering with pre_get_posts
- Stop header code from showing in category page?
- display all posts in current category
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- How to display regular posts & custom post types that fall under a category using just the generic category template?
- Get Custom post with ID
- How to filter custom post types by custom category taxonomy
- remove support for ‘Categories’ for a custom post type
- Remove date and category filters when editing custom post types
- Display all custom post types in archives.php
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Posts in Multiple Columns and Rows with one single loop
- Alphabetical sorting of custom post type – one letter per page
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- Custom post type archive sorted and grouped by date in post meta field
- How to display the categories of the post? (custom post type)
- Custom-post-type-archive: posts sorted/filtered by year?
- CPT posts listed by category with custom rewrite URL, please help!
- How to insert content from another Custom Post type into Post?
- Insert HTML inside link in a walker
- get_attached_media() on author page not working
- Getting posts under the custom post type ui category
- I would like to have different styles for my posts based on the content of each post
- Separate custom categories from default category
- How to get post type and month/year before while loop for date.php file
- What to and how to proceed with CPT to make DB small and efficient?
- School & class blogs: Categorize with categories or custom posts?
- How to get custom posts sub category link
- get_post_type is always post
- Custom Post type & Taxonomy 404
- Display the current post in browser as the first post in a loop (for a slideshow)
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Custom Sidebar in Editor (not Widget) for Custom Post Type in Genesis
- Loop Post Types with Name and Links
- Display all images from specific CPT
- Create a Custom Path to Archive
- Last post in loop – custom post types
- Get Posts List of Current Selected Custom Taxonomy in Shortcode
- How to show related posts of category on post within custom posttype
- Excluded Custom Taxonomy Term Posts Displaying in loop
- Custom Post Types – trying to make “title” display
- Looping to organize and display custom posts by category using PHP and WordPress
- My post loop needs to have 8 different post templates
- Change custom post type permalink according to category
- Want to display my custom date archive to date.php but dont know how
- Update Cateogory Taxonomy Count for Attachment Post Type
- Multiple Queries and Loops within CPT Archive
- Pagination not working with custom loop
- Display a custom post type list by taxonomy term
- Loop doesn’t work in single-product.php page but works at normal page
- Can a taxonomy of a custom post type be called ‘category’?