“Top Rated” widget conflict with search results
-
I have a widget to display Top 5 high rated posts. On all pages it’s working okay.
Each post displayed in the widget is attached to a custom taxonomy term.I built my search using WP standart. Then I needed to include custom taxonomy terms in my search results. I used this snippet to achieve that: https://gist.github.com/bueltge/1016587
The code added custom taxonomy terms in my search results.Whenever I search for a custom taxonomy term, my Top5 widget suddenly starts listing posts ONLY attached to the term being searched. For example: When I search for “Ozodbek Nazarbekov” (which is a custom taxonomy term), as long as I’m on the search results page the widget displayes posts attached to the “Ozodbek Nazarbekov” taxonomy term:
I believe the Thumbs Rating plugin is somehow grabbing the $category from the search results template.
Here’s what I’m using to list Top5 posts:
while($thumbs_ratings_top_query->have_posts()){ $thumbs_ratings_top_query->the_post(); $return .= '<li>'; $return .= '<h4 class="widget-ad-title standart-link"><a href="' . get_permalink() . '">' . get_the_title() . '</a><h4>'; $return .= '<h5 class="top-five-subtitle">' . get_the_term_list( $thumbs_ratings_top_query->post->ID, 'singer' ) . '<h5>'; } $return .= '</li>'; $return .= '</ul>'; // Reset the post data or the sky will fall wp_reset_postdata();
The “singer” is the custom taxonomy term.
This is the search results loop:
<?php while ( have_posts() ) : the_post(); ?> <li class="search-result-li"> <div class="single-result"> <?php $type = get_post_type($post); if ($type == 'music') { $faicon = 'fa-music'; } elseif ($type == 'clip') { $faicon = 'fa-play-circle-o'; } ?> <i class="fa <?php echo $faicon; ?>" aria-hidden="true"></i> <h4 class="result-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <p class="result-meta"><i>Qo'shiqchi:</i> <?php echo get_the_term_list( $post->ID, 'singer' ); ?></p> </div> </li> <?php endwhile; ?>
- The topic ‘“Top Rated” widget conflict with search results’ is closed to new replies.