I'm working on developing a WordPress plugin using two types of post. The first type is created and updated normally, and I'm trying to use it to create a dropdown
in the second type. However, when I call the function that generates the array for the post I'm working on, all other metaboxes' data is lost.
Function code that returns the array:
function array_integrantes($custom) {
global $post;
$old_post = get_post_custom($custom->ID);
$type = 'clero';
$args=array(
'post_type' => $type,
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
while ($my_query->have_posts()) : $my_query->the_post();
$integrantes[] = array(
'nome_integrante' => get_the_title(),
'link_integrante' => get_permalink()
);
endwhile;
}
wp_reset_postdata();
wp_reset_query();
$post = get_post_custom($old_post->ID);
return $integrantes;
}
Code where I call the function:
function paroquia_info($post) {
$custom = get_post_custom($post->ID);
$paroco = $custom["paroco"][0];
$vigarios = $custom["vigarios"][0];
$endereco = $custom["endereco"][0];
$cep = $custom["cep"][0];
$cidade = $custom["cidade"][0];
$telefone = $custom["telefone"][0];
$email = $custom["email"][0];
$site = $custom["site"][0];
$facebook = $custom["facebook"][0];
$integrantes = array_integrantes($custom);
echo'treco bugado<br><br><br>';
foreach ($integrantes as $row) {
echo $row['nome_integrante'].'<br>';
echo $row['link_integrante'].'<br>';
}
?>