• I am trying to do a query in a metabox on a custom post type. I’ve done a great deal of research on this – using WP_Query, or get_posts(), and everything is causing the same problem.

    Basically, whenever I run the query, it changes the fields in the actual post. Its like its interfering with the main loop. I’ve tried running resetting the query, and various combinations and it all acts up. Below is an example of one thing I’ve tried. Any other ideas?

    <ul>
    <?php
    global $mypost;
    $args = array('category' => 1 );
    $myposts = get_posts( $args );
    foreach( $myposts as $mypost ) :	setup_postdata($mypost); ?>
    	<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
    <?php endforeach; ?>
    </ul>
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Query in metabox messing up main loop’ is closed to new replies.