1
我遇到了一個奇怪的bug與Wordpress 3.8。WordPress的元框覆蓋頁面彈頭
我正在做的是在自定義帖子類型的多選上創建一個元框。這很好,因爲我可以選擇多種類型,保存帖子,並在頁面上顯示多個項目(在這種情況下,調用動作)。
奇怪的是,當我在Wordpress中更新頁面時,頁面的slu((固定鏈接)變成最後的 $ ctas查詢中的調用動作類型的標題。
什麼東西都伸出來了?這發生在if ($ctas->have_posts()
區塊中。
// Disply the selection of CTAs in a meta box
function xxxxx_calloutContent($post) {
// Get all the callouts
$args = array('post_type' => 'callout', 'posts_per_page' => '100');
$ctas = new WP_Query($args);
$assignedCallouts = explode(',',get_post_meta($post->ID, 'callouts', true));
// Create the meta box form
wp_nonce_field('xxxxxCallout', 'xxxxxCalloutForm');
if (count($assignedCallouts) > 3) {
xxxxx_ctaErrorMessage('Only three CTAs are allowed. Please choose three.');
add_action('admin_notices', 'xxxxx_ctaErrorMessage');
}
echo '<label for="calloutSelect">Choose your CTAs</label><br>';
echo '<select id="xxxxxCTASelect" name="xxxxxCTASelect[]" multiple="multiple">';
if($ctas->have_posts()) {
while($ctas->have_posts()) {
$ctas->the_post();
if (in_array(get_the_ID(), $assignedCallouts)) {
echo '<option selected="selected" value="'.get_the_ID().'">'.get_the_title().'</option>';
} else {
echo '<option value="'.get_the_ID().'">'.get_the_title().'</option>';
}
}
} else {
echo '<option value="" disabled="disabled">No Callouts</option>';
}
echo '</select>';
wp_reset_postdata();
}