How to change echo to return in shortcode
-
Greeting all,
I am trying to insert custom field with name of “Screenshot” (there are several of them) to the shortcode as below:
$mykey_values = get_post_custom_values('Screenshot'); foreach ( $mykey_values as $key => $value ) { echo '<img src="'.$value.'" alt="Screenshot" />'; }
But when you use echo in shortcode, it will be placed in the wrong position (top of the post). According to WP Codex, you will have to use return and I am wondering how I can change the code above to return all my custom fields with the name of “Screenshot” to the shortcode. Thank you very much.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘How to change echo to return in shortcode’ is closed to new replies.