Support » Plugins » reset post id

  • When using the following code:

    <?php $news = get_post_meta($post->ID, 'Related news', false); ?>
    <?php if($news) : ?>
    <h3>Related news</h3>
    <?php foreach ($news as $new) : ?>
    <?php $my_query = new WP_Query("p=$new");
    while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <b><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></b>
    <?php endwhile; ?>
    <?php endforeach; ?>
    <?php endif; ?>

    the id of the last ($my_query->have_posts()) : $my_query->the_post(); is being retained. How can I reset id back to current post?

Viewing 2 replies - 1 through 2 (of 2 total)
  • vijayrajesh

    (@vijayrajesh)

    hey you got the solution. I am having similar problem.

    vijayrajesh

    (@vijayrajesh)

    yes, i fixed it.

    in the beginning of page, i remembered the current post variable to some variable.

    So whenever needed, i used that variable.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘reset post id’ is closed to new replies.