Support

Account

Home Forums Backend Issues (wp-admin) CPT field in post -> strange ID on loop behavior

Unread

CPT field in post -> strange ID on loop behavior

  • I want to link post to CPT named groups.

    so i added a field type relation set to my CPT.

    now i loop thru posts like this

    global $wp_query;
    	global $post;
    	$args = array(
    		'post_type' => 'post',
    		'posts_per_page' => 1,
     	);
    	$loop = new WP_Query( $args );
        $data = '';
    	if ( $loop ) :
                while ( $loop->have_posts() ) : $loop->the_post();
                endwhile;
            endif;

    Strange thing is when i link some CPT post inside post i get CPT post id inside loop.

    For example
    Post id is 100
    CPT type id is 123

    If i make get_the_ID() inside while loop i get two items 100 and 123.

    How do i prevent of getting CPT which is linked to post??

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.