Unable to Add Custom Loop in Sidebar
-
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?
- The topic ‘Unable to Add Custom Loop in Sidebar’ is closed to new replies.