I have a post name player_list.This page has some post meta data.I want to show one of them in another page.I want to show player number.This metabox id is $pb_squad_number.

In another page. I have a metabox where I am selecting some players from the player_list post.Now I want to show the selected players number I assigned in that metabox of player_list post.I used following code but shows nothing.Post thuimbnail and title are working fine.


          $home_starting_player_names = rwmb_meta( 'pb_home_starting_player_options', array( 'multiple' => true ) ); ?>
           foreach ( $home_starting_player_names as $home_starting_player ){?>
            <li role="presentation">
            <aside class="starting-player-image"><?php  echo get_the_post_thumbnail($home_starting_player); ?></aside>
            <aside class="starting-player-number"><?php  echo get_the_title($home_starting_player); ?></aside>
           <aside class="starting-player-name"><?php  echo get_post_meta($home_starting_player, $pb_squad_number); ?></aside>
       <?php } 


echo get_post_meta($home_starting_player, $pb_squad_number, true);

The code you have returns an array; the third parameter specifies a single value.

| improve this answer | |
  • Hi - if this worked for you then please consider accepting the answer. – Andy Macaulay-Brook Oct 14 '16 at 11:45

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.