• Resolved creativitykills

    (@creativitykills)


    Is there a reason why posts dont get sorted by comments? I have tried and tried just not working. I have the Jetpack comments enabled so could this be the problem??

    I have pasted the custom page template so you guys can see because i’m stomped

    <?php
    /*
      Template Name: Popular Posts
    */
    
    get_header();
    
    $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
    
    // WP_Query arguments
    $args = array (
    	'post_type'              => array('post'),
    	'pagination'             => true,
    	'posts_per_page'         => '12',
    	'order_by' 				 => 'comment_count',
    	'order'					 => 'DESC',
    	'paged'					 => $paged,
    	'ignore_sticky_posts'	 => true,
    );
    
    $orig_post = $post;
    
    // The Query
    $wp_query = new WP_Query( $args );
    
    // The Loop
    if ( $wp_query->have_posts() ): ?>
    <div class="articles-list">
    	<div class="list-em">
    		<div id="articles-container">
    		<?php while ( $wp_query->have_posts() ): $wp_query->the_post(); ?>
    
    		<?php
    			/* Include the Post-Format-specific template for the content.
    			 * If you want to override this in a child theme, then include a file
    			 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
    			 */
    			get_template_part( 'content', get_post_format() );
    		?>
    
    		<?php endwhile; ?>
    
    		<?php $post = $orig_post ?>
    
    		<?php the_posts_navigation(); ?>
    
    		</div>
    	</div>
    </div>
    <?php else: ?>
    
    	<?php get_template_part( 'content', 'none' ); ?>
    
    <?php endif; ?>
    
    <?php wp_reset_postdata() ?>
    <?php // wp_reset_query() ?>
    <?php get_footer() ?>
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Sorting Posts By Comment Count NOT WORKING’ is closed to new replies.