• Resolved accuratelimited

    (@accuratelimited)


    Your theme includes a lovely widget that shows comments, posts and tags. However, I don’t have any comments on the site so wanted to use the comments tab as a way to show custom-post-type. It’s for a referee association which wants to display referee profiles. The CustomPostType was added in the functions file. As the below explains, it does work occasionally.

    It works perfectly on Pages (Shows only Referee Profiles), Tag Archive, Search Archive and Blog Homepage (i.e. not custom homepage). Unfortunately it doesn’t always work, it shows the most recent posts when on a single post, category archive and, oddly, the referee profile.

    This is the code (adjusted from your own – I added the wp_reset_query hoping it would fix it):

    <div class="tab-pane fade" id="arra-comments">
    		<?php
    
    			$args = array( 'post_type' => 'referee', 'posts_per_page' => $noc, 'post_status' => 'publish' );
    			$refereeshow = new WP_Query( $args );
    
    			while( $refereeshow->have_posts() ) : $refereeshow->the_post(); ?>
    				<div class="ams-post">
    					<div class="ams-thumb">
    						<?php if ( has_post_thumbnail() ) { ?>
    							<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_post_thumbnail( 'small-thumb', array('title' => get_the_title()) ); ?></a>
    						<?php } else { ?>
    							<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img  src="<?php echo get_template_directory_uri(); ?>/images/mini-thumbnail-default.jpg" alt="<?php the_title(); ?>" /></a>
    						<?php } ?>
    					</div>
    					<div class="ams-details">
    						<?php the_title( sprintf( '<h1 class="ams-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h1>' ); ?>
    						<p class="ams-meta"><?php the_time('F j, Y'); ?></p>
    					</div>
    				</div>
    			<?php
    			endwhile;
    			wp_reset_query();
    		?>
    
    </div><!-- .tab-pane #arra-comments -->

    I am currently adjusting the theme to be used on a live site and am doing so using Web Matrix so I am unable to post a link to a site.

    Do you have any idea what might be causing it, something in the core theme that might have been overlooked before release?

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

    (@accuratelimited)

    Please disregard above. I had also added this code

    function myprefix_add_custom_types( $query ) {
      if( is_category() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'referee'
    		));
    	  return $query;
    	}
    
    if( is_single() && empty( $query->query_vars['suppress_filters'] ) ) {
        $query->set( 'post_type', array(
         'post', 'referee'
    		));
    	  return $query;
    	}
    }
    add_filter( 'pre_get_posts', 'myprefix_add_custom_types' );

    I have now removed it and it’s working again. Sorry.

Viewing 1 replies (of 1 total)
  • The topic ‘Unable to Add Custom Loop in Sidebar’ is closed to new replies.