I am using following codes to show title of a post in another post.But it shows only post id.How to solve this?
<?php $home_team_name = rwmb_meta( 'pb_select_home_team', 'type=select_advanced', get_the_ID() ); ?>
<?php echo esc_html( $home_team_name ); ?>
Thanks
2 Answers
Because you’re outside the loop, you’ll need to either know the post id of the title you want and specify it in the function parameter, or call the global $post variable if you’re on the page (just not in the loop yet).
global $post
echo get_the_title($post->ID);
or
echo get_the_title(2);