0

I got 2 fields in group ordered by toolset-post-sortorder meta_key:

youtube_id: TeBW-WByzlw 144 163
youtube_id: CEdYPEKDD2E 255 270

This it how it look in DB: enter image description here

This is how I try to get fields:

$videoId_arr = array();
$child_posts = toolset_get_related_posts( get_the_ID(), 'playlist_item', array( 'query_by_role' => 'parent', 'return' => 'post_object' ));
foreach ($child_posts as $child_post) {
  $videos_ids = types_render_field( "youtube_id", array( "id"=> "$child_post->ID") );  
  $videos = explode(" ",$videos_ids); 
  array_push($videoId_arr, $videos[0]);
}

This is result with wrong order:

Array [ "CEdYPEKDD2E", "TeBW-WByzlw" ]

Please help me fix it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.