Shortcodes won’t work on live environment

So this turned out to be the problem: After running using WP_DEBUG on the live site it turned out $this was not defined in the following line: public function __construct(){ add_action(‘init’, function(){ add_shortcode(‘bbit’, array($this, ‘shortcode_handler’)); }); } shortcode_handler is a non-static function here, and this code was all called in a static context. It seems … Read more

Add shortcode support to custom field

@see https://codex.wordpress.org/Function_Reference/do_shortcode Searches content for shortcodes and filters shortcodes through their hooks: echo do_shortcode( get_post_meta( THE_ID_OF_YOUR_POST, THE_NAME_OF_YOUR_CUSTOM_FIELD, true ) );

Nesting shortcodes results in the inner shortcode being placed AFTER outer shortcode

Use Output buffering for the best result of shortcode, especially when you are outputting some HTML in it: function f_girl_shortcode( $atts , $content = null ) { ob_start(); ?> <div class=”talk girl”><?php echo do_shortcode($content); ?></div> <?php return ob_get_clean(); } add_shortcode( ‘talk-girl’, ‘f_girl_shortcode’ ); and function p_generic_shortcode( $atts , $content = null ) { ob_start(); ?> … Read more

Shortcode not working with WordPress updated

Try removing the brackets and adding the full url: $url=”http://theurl.com”; And for clarity, it’s best to use different names for the tag and function name: add_shortcode(‘aggrenda’, ‘aggrenda_func’); function aggrenda_func() { $url=”http://theurl.com”; $response = wp_remote_get( $url ); echo($response); }

Hook WP_Embed run_shortcode

Hooks are only available when you see apply_filters, apply_filters_ref_array, do_action, and do_action_ref_array. They are all basically handled the same way but have some small differences like filters always expecting a returned value. e.g.: // seeing this in some WordPress code $the_content = apply_filters( ‘the_content’, $the_content ); // means you can then use something like this … Read more