• Resolved cjjr82

    (@cjjr82)


    Hello All,
    I have setup custom category archive pages for each category on my site. I have custom post type ‘Artists’ and category ‘Bands’, however when displaying the category archive for ‘Bands’ not all of the Bands show up on the page, and I can not figure out why.
    This is the opening code for my category archive

    
    get_header();
    ?>
    
    <div id="primary" class="content-area">
    	<main id="main" class="site-main" role="main">
    		<?php 
      if ( have_posts() ) { 
        while ( have_posts() ) {
          the_post();
          $wp_query->the_post();

    I then used pre_get_posts to pull the correct category

    function set_category_query($query) {
      if((is_category() || is_tag()) && $query->is_main_query()) {
        $post_type = get_query_var('post_type');
        $query->set('orderby','title');
        $query->set('order','ASC');
        if ( is_category('bands')) {
          $query->set('post_type','artists');
          $query->set('cat','bands');
        } elseif($post_type) {
          $post_type = $post_type;
        }
        return $query;
      }
    }
    
    add_filter('pre_get_posts', 'set_category_query');

    There should be a band listed right at the beginning as ’10 Minutes Down’ however that band does not show on the Bands Category Archive page.

    Any suggestions would be greatly helpful!!
    Thanks!

    • This topic was modified 6 years, 7 months ago by cjjr82.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Thread Starter cjjr82

    (@cjjr82)

    After playing around with it more, of course I figured it out after posting.
    After the
    while ( have_posts() ) {
    I had
    $wp_query->the_post();
    which should not have been there. Took that out and problem solved.
    PALM TO FACE!

Viewing 1 replies (of 1 total)
  • The topic ‘Custom Category Archive not Showing All Posts’ is closed to new replies.