Create a page template for “top rated posts” but show full content and not just a list
Sorry upfront if I’m not explaining this clearly. I’m using WP-PostRatings and it has this function:
<?php if (function_exists('get_most_rated')): ?>
<ul>
<?php get_most_rated(); ?>
</ul>
<?php endif; ?>
Throwing that code in a template page shows a linked list of the top posts by user ratings but it’s not showing the full content of each post which is what I want. I believe I need to tap into the loop or create a custom query for this function?
For example, I made a custom page template to show a list of all my posts but doing this with a plugin’s function is where I get lost. How do I wrap the following page template in with this get_most_rated();
function so it uses the WP-PostRatings function and displays the top rated post as full content?
<?php
// set up or arguments for our custom query
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query_args = array(
'post_type' => 'post',
'post_status'=>'publish',
'posts_per_page' => 11,
'paged' => $paged
);
// create a new instance of WP_Query
$the_query = new WP_Query( $query_args );
?>
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); // run the loop ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('group post-standard'); ?>>
<div class="post-inner">
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php if ( has_post_thumbnail() ): ?>
<?php hu_the_post_thumbnail('beatpost-thumb'); ?>
<?php elseif ( hu_is_checked('placeholder') ): ?>
<img src="<?php echo get_template_directory_uri(); ?>/assets/front/img/thumb-standard.png" alt="<?php the_title(); ?>" />
<?php endif; ?>
<?php if ( has_post_format('video') && !is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-play"></i></span>'; ?>
<?php if ( has_post_format('audio') && !is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-volume-up"></i></span>'; ?>
<?php if ( is_sticky() ) echo'<span class="thumb-icon"><i class="fa fa-star"></i></span>'; ?>
</a>
<?php if ( comments_open() && ( hu_is_checked( 'comment-count' ) ) ): ?>
<a class="post-comments" href="<?php comments_link(); ?>"><span><i class="fa fa-comments-o"></i><?php comments_number( '0', '1', '%' ); ?></span></a>
<?php endif; ?>
</div><!--/.post-thumbnail-->
<div class="post-content">
<h2 class="post-title entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</h2><!--/.post-title-->
<div class="beat-share"><span class="beat-social-button-fb"><a href="javascript:void(0);" onclick="PopupCenter('https://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>', 'myPop1',531,545);"><i class="fa fa-facebook"></i></a></span> <span class="beat-social-button-twit"><a href="javascript:void(0);" onclick="PopupCenter('https://twitter.com/share?text=<?php the_title();?>>> Buy and Download Hundreds of Rap Beats&via=RockItPro&hashtags=buyrapbeats&url=<?php the_permalink();?>', 'myPop1',539,253);"><i class="fa fa-twitter"></i></a></span></div>
<div class="entry excerpt"><?php the_content(); ?></div>
<div class="post-meta group">
<p class="post-byline" style="display:none;"><span class="vcard author"><span class="fn"><a href="https://www.rockitpro.com/author/Sho-Down/" title="Posts by Sho-Down" rel="author">Sho-Down</a></span></span></p><p class="post-category"><?php the_category(', '); ?></p><p class="post-date date updated published"><i class="fa fa-angle-double-right"></i><?php the_time('m/d/Y'); ?><span class="anglemobile"><i class="fa fa-angle-double-right"></i></span></p><p class="cat-posts"><a href="<?php comments_link(); ?>"><span><i class="fa fa-comments-o"></i> <?php comments_number( '0', '1', '%' ); ?><span class="comment-text"> Comments</span></span></a></p>
</div><!--/.post-meta-->
</div><!--/.post-content-->
</div><!--/.post-inner-->
</article><!--/.post-->
<?php endwhile; ?>
<div id="navigation">
<?php $big = 999999999; // need an unlikely integer
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'mid_size' => 2,
'end_size' => 1,
'total' => $the_query->max_num_pages
) ); ?>
</div>
<?php else: ?>
<article>
<h1>Sorry...</h1>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
</article>
<?php endif; ?>
</div><!--/.hu-pad-->
</section><!--/.content-->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Leave an answer
You must login or register to add a new answer .