WordPress.org

Ready to get started?Download WordPress

Forums

Pagination and Comments not working together (1 post)

  1. adammydesign
    Member
    Posted 1 year ago #

    Hi Everyone

    I got so far with this but I have hit a wall with production because of a problem. My landing page is a list of posts and clicking on the number of comments causes a drop down of current comments and the form. This was all working fine but when I try to add pagination the <?php comments_template(); ?> doesn't return anything. Can anyone spot what I am doing wrong.

    <!-- Posts Query -->
    <?php
    //Fix homepage pagination
    
    if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } else if ( get_query_var('page') ) {$paged = get_query_var('page'); } else {$paged = 1; }
    $temp = $home_query;  // re-sets query
    $home_query = null;   // re-sets query
    $args = array( 'post_type' => 'post', 'posts_per_page' => 2, 'paged' => $paged);
    $home_query = new WP_Query();
    $home_query->query( $args );
    
    while ($home_query->have_posts()) : $home_query->the_post();
    
    ?>
    
    <!-- Home Post -->
    <div class="home_post group mb20">
    
    	<!-- Home Post Head -->
    	<div class="home_post_head group mb20">
    
    		<!-- Title -->
    		<h1 class="left post_title"><?php the_title(); ?></h1>
    		<!-- Date -->
    		<h3 class="left post_date"><?php the_time('d.m.y'); ?></h3>
    
    		<!-- Comment Link -->
    		<div class="post_comment_link right">
    			<a href="#" class="comment_expand">
    				<span class="fill">
    					<h3 class="small comment_number"><?php comments_number( 00, 1, '%' ); ?></h3>
    				</span>
    			</a>
    		</div>
    
    		<!-- Post Comments Container -->
    		<div class="comments_container left">
    			<?php comments_template(); ?>
    		</div>
    
    	</div>
    	<!-- Home Head Close -->
    
    	<!-- Post Content -->
    	<div class="home_post_content">
    		<?php the_content(); ?>
    	</div>
    
    	<!-- Post Tags -->
    	<p class="tags"><?php the_tags('', ', ', ''); ?></p>
    
    	<!-- Social Links -->
    	<div class="social_links group">
    
    		<!-- Facebook Like and Share -->
    		<div class="fb-like social_link" data-href="<?php the_permalink(); ?>" data-send="true" data-layout="button_count" data-width="450" data-show-faces="true" data-font="arial"></div>
    
    		<!-- Tumblr Share -->
    		<div class="social_link">
    			<a href="http://www.tumblr.com/share/photo?source=<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>&caption=<?php the_title(); ?>&clickthru=<?php the_permalink(); ?>" title="Share <?php the_title(); ?> on Tumblr" style="display:inline-block; text-indent:-9999px; overflow:hidden; width:20px; height:20px; background:url('http://platform.tumblr.com/v1/share_4.png') top left no-repeat transparent;"></a>
    		</div>
    
    		<!-- Twitter Button -->
    		<div class="social_link">
    			<a href="https://twitter.com/share" class="twitter-share-button" data-url="<?php the_permalink(); ?>" data-text="<?php the_title(); ?>" data-count="none">Tweet</a>
    		</div>
    
    		<!-- Pin it Link -->
    		<div id=”pinterest-button-for-wordpress” class="social_link">
    			<a href=”http://pinterest.com/pin/create/button/?url=<?php the_permalink() ?>&media=<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>&description=<?php the_title(); ?>” data-pin-do="buttonPin" data-pin-config="none"><img src="//assets.pinterest.com/images/pidgets/pin_it_button.png" /></a>
    		</div>
    
    		<!-- Email Share -->
    		<div class="social_link">
    			<a href="mailto:?subject=<?php echo the_title(); ?>&body=Take%20a%20look%20at%20this%20<?php echo the_permalink(); ?>" id="mail_icon"><img src="<?php directory(); ?>/images/email.png" title="Share via email" rel="" /></a>
    		</div>
    
    		<!-- Google Plus One -->
    		<div class="g-plusone social_link" data-size="medium" data-annotation="none" data-href="<?php the_permalink(); ?>"></div>
    	</div>
    
    </div>
    
    <?php endwhile; ?>
    
    <!-- Posts Pagination -->
    <div class="pagination_home">
    <?php
    paginate();
    $home_query = null;
    $home_query = $temp; // Reset
    
    ?>
    </div>

    Thanks in advance.

Topic Closed

This topic has been closed to new replies.

About this Topic