how to show the syntax of a shortcode
If you use double brackets, WordPress will not execute the shortcode but just display it with single brackets. So becomes in your post.
If you use double brackets, WordPress will not execute the shortcode but just display it with single brackets. So becomes in your post.
Something I forgot in my previous comment was that shortcodes return content, both the suggested include and my alternative get_template_part will directly output the content (which is what you are seeing with the content appearing at the top of your page instead of where the shortcode is called). To counteract this we must use output … Read more
Have a look at my guide here – http://www.wpexplorer.com/wordpress-tinymce-tweaks/ – so you can see how to create a popup window where you can select your options than insert a shortcode. If you download my Free Symple Shortcodes plugin you can see a live implementation as well. Instead of having the user select the posts to … Read more
WP v3.3 gave us the ability to run wp_enqueue_script in the middle of a page. Ticket 9346 This has made it much easier to include your JS with better granularity (when using shortcodes, at least). Here, jquery will be only included when our shortcode is fired. function get_slideshow() { // Do some stuff… // Load … Read more
Instead of calling do_shortcode() just call the function associated with the shortcode. Example There is a shortcode named [example] and a function registered as shortcode handler: function example_shortcode( $atts = array(), $content=”” ) { extract( shortcode_atts( array ( ‘before’ => ”, ‘after’ => ”, ), $atts ) ); return $before . $content . $after; } … Read more
Here is how you should create shortcode. First you will have to define $atts item in get_userdata because $atts is an array. Also I think there is also some issues with uppercase attributes names, so you should use attribute in lower case. So instead of userID, use userid. function getUserEmail_func( $atts ) { $user_info = … Read more
As @Rarst explains, shortcodes normally run too late for you to redirect from inside one. They usually run on the the_content hook which is well after content is sent to the browser. If you need to redirect based on the presence of a shortcode you need to check for that shortcode before any content leaves … Read more
As the error says you need an instance of the class to use $this. There are at least three possibilities: Make everything static class My_Plugin { private static $var=”foo”; static function foo() { return self::$var; // never echo or print in a shortcode! } } add_shortcode( ‘baztag’, array( ‘My_Plugin’, ‘foo’ ) ); But that’s not … Read more
Like it was mentioned before removing the shortcode and re-adding it is not the compatible with other plugins modifying galleries so instead you use the post_gallery filter hook and the same code from the gallery_shortcode function but with your own modification for example, I’ve commented out the parts you don’t want: function fix_my_gallery_wpse43558($output, $attr) { … Read more
There’s two ways you can go about this, but both involve creating a function that does pretty much the same as the existing gallery shortcode function… You can either.. Hook onto post_gallery and manipulate the incoming data(you can use the gallery shortcode function as a base for the filter if necessary) Unregister the gallery shortcode … Read more