• Resolved sclausen

    (@sclausen)


    In my header i’ve got this code:

    <?php
    	$args = array( 'numberposts' => 1, 'orderby' => 'recent', 'cat' => '-7,-8,-9');
    	$rand_posts = get_posts( $args );
    	foreach( $rand_posts as $post ) : ?>
    		<a href="<?php the_permalink(); ?>">
    		<?php echo get_the_post_thumbnail($post->ID); ?>
    		<div id="newestpost" class="bg50 absolute">
    		<h1 href="<?php the_permalink(); ?>"><?php the_title(); ?></h1>
    		</div></a>
    	<?php endforeach; ?>

    And this code does something, to the next and previous links..

    If i remove it, the links work again.
    But i dont want to remove the feature..

    Can anyone help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • your foreach loop uses the $post variable, which is also a global variable used in the original query and in the loop;

    try to reset the data at the end of your code, by ading wp_reset_query(); directly after the endforeach;

    Thread Starter sclausen

    (@sclausen)

    Dude! Thank you! 😀

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Next_post_link and Previous_post_link not working’ is closed to new replies.