0

i have problem. I use this code before comment form.

<?php

global $post;

$args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 1 );

$myposts = get_posts( $args );

foreach ( $myposts as $post ) : setup_postdata( $post ); ?>

        <?php the_permalink(); ?><?php the_title(); ?>

<?php endforeach; ?>

I have in single.php:

1 -- post content

2 -- recent post

3 -- form comment

But when i comment something my comment is not on post but was added to last recent post. How can i do this?

I tried to use this:

<?php
$args = array(
    'posts_per_page'   => 1,
    'category__not_in' => array( 23, 24 )
);

$recent_posts = get_posts( $args );

foreach ( $recent_posts as $recent ) {
    echo '<a href="' . get_permalink( $recent ) . '">Latest Post</a>';
}
?>
0

You should add wp_reset_postdata after outputting your recent posts.

  • Ya that is what i need. Thx. – user33913 Aug 6 '13 at 7:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.