Hello I am trying to show a custom field 'twitter-user' within a shortcode that is used within the theme of my site. Can someone help me with the correct code, I realise that the below won't work.
<?php echo do_shortcode('[twitter-widget username="<?php echo get_post_meta( get_the_ID(), 'twitter-user', true ); ?>"]'); ?>
Thank you
Francisco Javier Carazo Gil answers:
<?php echo do_shortcode('[twitter-widget username="<?php echo get_post_meta( get_the_ID(), 'twitter-user', true ); ?>"]'); ?>
Is bad formed, try with:
<?php echo do_shortcode('[twitter-widget username="' . get_post_meta( get_the_ID(), 'twitter-user', true ) . '"]'); ?>
Arnav Joy answers:
try this
<?php echo do_shortcode('[twitter-widget username="'.get_post_meta( get_the_ID(), 'twitter-user', true ).'"]'); ?>
Hariprasad Vijayan answers:
Hello,
Try this
<?php echo do_shortcode('[twitter-widget username="'.get_post_meta( get_the_ID(), 'twitter-user', true ).'"]'); ?>
Fahad Murtaza answers:
<?php
$twitter_id=get_post_meta( get_the_ID(), 'twitter-user', true );
echo do_shortcode('[twitter-widget username="'.$twitter_id.'"]');
?>
Fahad Murtaza comments:
wow, 4 responses as I just typed my solution :) wpquestions is amazing :)