When I use the following code in a (wpalchemy) custom meta box, everything works fine. That is until I pressed 'add new'. At this point, the title, slug, featured image, etc.. are being pre-populated with the content from my 'products' post type.
The code builds a drop down within my 'case studies' post-type, and populates it with post titles/ids from my 'projects' post type.
How can I use the loop in the backend like this without messing stuff up. I tried with get_posts
as well as WP_Query.
global $post;
$args = array( 'post_type' => 'projects', 'posts_per_page' => 200 );
$custom_posts = get_posts($args);
foreach($custom_posts as $post) : setup_postdata($post);
echo '<option value="' . get_the_id() . '"';
echo '>' . get_the_title() . '</option>' . "\n";
endforeach;
Edit: A little more background:
I'm using the wpalchemy class for custom meta boxes. The following code is included in my functions.php file, after /wpalchemy/MetaBox.php
https://github.com/farinspace/wpalchemy/blob/dev/wp-content/wpalchemy/MetaBox.php
$assoc_project = new WPAlchemy_MetaBox(array(
'id' => '_assoc_project',
'title' => 'Associated Project',
'template' => get_stylesheet_directory() . '/metaboxes/case-studies-assoc_proj-meta.php',
'types'=> array('case-studies')
));
Edit 2: Update
I've tried and replicated this problem accross multiple browsers on my PC, but I just had a co-worker try on Ffox/mac and they don't have the problem. I don't understand why this would be platform specific - but there it is...