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.


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.

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.