I'm having trouble to exclude specific posts in wp_dropdown_pages. Exclude seems to work, but the first ID of my foreach is ever and ever include in the dropdown... I don't understand why...
My get_posts query
$exclude_posts = get_posts(array(
'post_type' => 'organic-pickup',
'tax_query' => array(
array(
'taxonomy' => 'type',
'field' => 'term_id',
'terms' => 72 //TODO Get all ID of taxonomy 'type' terms where types_metabox_dropdown = types_metabox_dropdown_no
)
)
));
My foreach with output formated to match wp_dropdown_pages parameters.
foreach($exclude_posts as $exclude_post) {
$excludes[] = $exclude_post->ID;
}
$exclude = implode(',',$excludes);
$excluded = "'" . $exclude . "'";
print_r($excluded);
My dropdown
$ogpk_pickup_field_args = array (
'depth' => -1,
'class' => 'store-pickup form-row-wide',
'show_option_none' => __( 'Choisissez le point relais où retirer votre panier', 'organic-pickup' ),
'name' => 'store_pickup',
'hide_empty' => false,
// 'exclude' => '1074,1072,1059',
'exclude' => $excluded, //TODO get excluded working please...
'post_type' => 'organic-pickup',
'value_field' => 'ID',
'suppress_filters' => true
);
wp_dropdown_pages( $ogpk_pickup_field_args );
I commentend out an exclude line with '1047,1072,1059'. With this param, the dropdown works fine and don't dispaly this posts. The print_r($excluded) display this exact string... but put in the dropdown param, it always display the post corresponding to the first ID... I'm completly unable to understand why... Any hint folks?