How to show an image via shortcode

This is basic function to create a shortcodes. Put this code in your functions.php function smile_shortcode() { $output = get_template_directory_uri() . ‘/images/smile.png’; // put your smile image here $_image=”<img src=”” . $output . ‘”>’; return $_image; } add_shortcode(‘smile’,’smile_shortcode’); Then go to your dashboard and post editor. Remember to put [smile] in your post. More: http://codex.wordpress.org/Function_Reference/add_shortcode

Shortcode and variable

For anyone that comes across this in the future, here is what I figured out: $askavl_instagram_contact_title = get_post_meta(get_the_ID(), ‘askavl_instagram_contact_title’, true); if(isset($askavl_instagram_contact_title) && $askavl_instagram_contact_title != “”) : $tag = str_replace(“#”,””, ((string)$askavl_instagram_contact_title) ); $thumbsize = “220px”; $image_limit = “2”; $easyInstagramSC = “[easy-instagram limit={$image_limit} caption_hashtags=false caption_char_limit=0 author_text=”” thumb_click=’thickbox’ time_text=”” thumb_size={$thumbsize} tag='{$tag}’]”; echo do_shortcode( $easyInstagramSC ); From what I … Read more

Including template in shortcodes

I’m not quite sure this is what you are trying to do, however, this is one way to use an external template file for your shortcode output. This is your shortcode function (e.g., in functions.php): function qt_shortcodez() { return include ‘template/shortcode.php’; } // function qt_shortcodez And that is the very output (i.e., shortcode.php): <?php ob_start(); … Read more

do_shortcode() won’t return PHP Array

This function returns a string. So you should join the elements of the array to make a string. From the Codex: Function Reference/do shortcode Return Values (string) Content with shortcodes replaced by the output from the shortcode’s handler(s).

Adding a custom field to do_shortcode [closed]

There’s a general convention in WordPress: functions prefixed with the_ will echo a value functions prefixed with get_ or get_the_ will return a value In your case you need to use get_sub_field() instead of the_sub_field() eg: echo do_shortcode( get_sub_field( ‘slideshare’ ) ); The documentation on the ACF site is very comprehensive: http://www.advancedcustomfields.com/resources/functions/get_sub_field/ NOTE: In your … Read more