WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Quick explanation : When I add a new "Company" (custom post type), I have a drop down menu listing all the companies to choose if the one i'm creating depends from another one. I got 3 metaboxes, the dropdown is in the first one.

In functions.php :
<select value="<?php echo $subsidiary; ?>" name="subsidiary">
$args = array( 'post_type' => 'company');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
<option value="<?php echo the_ID(); ?>" ><?php the_title() ?></option>

The dropdown is listing all the companies as i want, but when i create a new company, all fields located after my dropdown take the values from the first company in my list, and i can't change them. Any clues?

Thanks in advance.

share|improve this question

When you're calling $loop->the_post(), you're replacing the global $post instance. You need to call wp_reset_postdata() after your while loop.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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