• Hi

    Being a newer in wp ,having little confusion with loops.
    I am using my single-custom.php to display single posts.

    The page layout is as follows.

    first div containing the content of the single post ,then next its related posts.

    My problem is .I want to insert the comments template of my individual post after the related posts. But it displaying the last related post’s comments.

    I’m sure I’m making something wrong with loops. Shall anyone clarify?

Viewing 1 replies (of 1 total)
  • Thread Starter DhanyaAbraham

    (@dhanyaabraham)

    Code is here……………

    <div id="primary" class="widecolumn">
    	<div id="content" role="main">
    	<?php while ( have_posts() ) : the_post(); ?>
    <div class="post-post-tit">
    <a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a></div>	
    
    <div class="post-date_meta_tit">	<?php the_time('j F Y');?></div>
    <div class="post-cat_tit"><span class="span-post-cat_tit"> Categories- </span>
    						  <?php  	/* translators: used between list items, there is a space after the comma ---Here category title is printing*/
    									$categories_list = get_the_category_list( __( ' / ', 'twentytwelve' ) );
    									if ( $categories_list ):
    									?>
    
    									<?php	printf( __( '<span class="%1$s" id="cat-link1"> </span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-cat-links',$categories_list );
    									$show_sep = true; ?>
    
    									<?php  endif; // End if categories ?>
    						</div>
    
    <div class="post-entry-content">
    		<?php the_content();?>
    
    </div><!-- post.entry-content -->
    
    <div class="related-post">Possibly Related...</div>
    <div class="thumb-related-post">
    
    <?php
    $categories = get_the_category($post->ID);
    if ($categories) {
    	$category_ids = array();
    	foreach($categories as $individual_category) $category_ids[] = $individual_category->term_id;
    
    	$args=array(
    		'category__in' => $category_ids,
    		'post__not_in' => array($post->ID),
    		'showposts'=>4, // Number of related posts that will be shown.
    		'caller_get_posts'=>1
    	);
    	$my_query = new wp_query($args);
    	if( $my_query->have_posts() ) {
    		echo ' ';
    		while ($my_query->have_posts()) {
    			$my_query->the_post();
    ?>
    		<div class="thumb-related-post-wrapper">
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    				<span class="post-tit-pad"><?php the_title(); ?></span>
    					<div class="post-cat_tit_bot">
    						   <?php  	/* translators: used between list items, there is a space after the comma ---Here category title is printing*/
    										$categories_list = get_the_category_list( __( ' /  ', 'twentytwelve' ) );
    										if ( $categories_list ):
    								?>
    
    										<?php	printf( __( '<span class="%1$s" id="cat-link1"> </span> %2$s', 'twentytwelve' ), 'entry-utility-prep entry-utility-prep-cat-links',$categories_list );
    											$show_sep = true; ?></a>
    
    									<?php  endif; // End if categories ?>
    						</div>
    		<div class="thumb-img-pad"><a href="<?php the_permalink(); ?>" rel="bookmark">	<?php the_post_thumbnail(); ?></a></div>
    		<div class="post-date_meta">	<?php the_time('j F Y');?>
    		<span class="post-commnt_meta"><?php comments_number( 'No Comments', '1 comment', '% comments' ); ?></span></div></div>
    		<?php
    		}
    		echo ' ';
    	}
    }
    ?>
    				</div><!--#thumb-related-post-->
    
    			<?php comments_template(); ?>
    
    			<?php endwhile; // end of the loop. ?>		
    
    			</div><!-- #content -->
    
    	</div><!-- #primary -->

Viewing 1 replies (of 1 total)
  • The topic ‘How to get the current post's comment after inserting the related posts of that’ is closed to new replies.