I have a custom post type in my WordPress that authors will send new posts in it. I want to display a list of posts in “Edit” page of that custom post type in admin panel.
So I created a meta box and used a code to get posts from another custom post type (it suppose to be such a quick posts that i had to add it).
Meta box added fine, posts getting fine, but when i enter edit page, another custom fields (Advanced custom fields) will fully clear and empty! When I remove that post’s list code, field’s data will show but when i add getting post’s code, it will clear fields data.
this is code for getting posts list:
<?php
global $post;
$post_id = $_GET['post'];
$args = array( 'posts_per_page' => -1, 'post_type' => 'vosooli', 'meta_query' => array(array('key' => 'parvande_id_invosolli','value' => $post_id,),), );
$myposts = get_posts( $args );
foreach ( $myposts as $post ) :
setup_postdata( $post ); ?>
<?php $post_idm = get_the_ID(); ?>
<?php $vaziat_vosoolyi = get_post_meta($post->ID, 'vosooli_status', true); ?>
<a status="<?php echo $vaziat_vosoolyi; ?>" class="listvosoole vosoolshode" href="https://example.com/vosooli-info.php?id=<?php echo $post_idm; ?>" >
<?php $mablaaq = get_post_meta($post->ID, 'vosooli_mablaq', true); echo number_format($mablaaq, 0, '.', ','); ?>
<span><?php echo $vaziat_vosoolyi; ?></span>
</a>
<?php endforeach; wp_reset_postdata(); ?>
I think there is a problem to end postdata and end query and let page to continue loading fields data like wp_reset_postdata(); etc. Any advise?