Iâve got a metabox I set up using WPAlchemy that allows authors to add a link to an associated post. Itâs been working fine for months but now for some reason the dropdown with the appropriate posts isnât updating. Hereâs the code in the custom post meta php file:
<p>
<?php $mb->the_field(âproduct_video_IDâ); ?>
<select name=â<?php $mb->the_name(); ?>â>
<option value=â">None</option>
<?php
global $thispost;
$myposts = get_posts(ânumberposts=5000&offset=1â²);
foreach($myposts as $thispost) :
if (in_category(âProduct Videosâ, $thispost)) {
?>
<option value=â<?php echo $thispost->ID; ?>â <?php $mb->the_select_state($thispost->ID);?> ><?php echo get_the_title($thispost->ID); ?></option>
<?php } ?>
<?php endforeach; ?>
<?php setup_postdata($thispost);?>
</select>
</p>
I tried adding a couple test posts in the Product Videos category and they didnât show, either. I commented the lines that filtered for that category and the Meta box dropdown updated to show every post⦠except the one I wanted and the new test ones. Anybody have any idea what might be going on? Is there some part of the machinery here that isnât updating that I should fix? Thanks so much!
Try WP_Query to get the posts, since
get_posts()
also makes use of it: