• Resolved imarap

    (@imarap)


    Hi,
    In a single post page, I have some related content on the top and the current post in the bottom. Because the related content creates a loop, I cannot show the current post after.

    This is the related content loop:

    <?php
    	$scores = the_related_get_scores($post->ID, true);
    	$posts = array_slice( array_keys( $scores ), 0, 3 );
    	$args = array('post__in' => $posts, 'post_type' => 'project', 'posts_per_page' => 3 );
    	$my_query = new WP_Query( $args );
    		if ( $my_query->have_posts() ) {
    		while ( $my_query->have_posts() ) {
    		$my_query->the_post();?>
    
    	<!-- do stuff ... -->
    
    	<?php echo '';
            		}
        		}
        	else {
            echo "--";
        }
    ?>

    And this is the way I tried to display the current post, but it doesnt work:

    <?php if (have_posts()) : ?>
                   <?php while (have_posts()) : the_post(); ?>
                   <!-- do stuff ... -->
                   <?php endwhile; ?>
         <?php endif; ?>

    I dont have much experience on this, so any help would be appreciated. thanks

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘show the current post in a second loop’ is closed to new replies.