Default Attributes in Shortcode Not Working
Try: $atts = shortcode_atts( array( ‘title’ => ‘My Default’, ‘year’ => ‘1900’ ), $atts );
Try: $atts = shortcode_atts( array( ‘title’ => ‘My Default’, ‘year’ => ‘1900’ ), $atts );
Simply don’t call return more than once. Just add your output to a variable: $some_variable_name=”mention the = at the beginning of this line”; $some_variable_name .= ‘Take a look at the .Period before the = in this line’; $some_variable_name .= ‘then add more lines always with the period’; // at the end of your shortcode function: … Read more
do_shortcode should do the trick. I don’t think you need the ‘echo’ before it though, I have never done so myself and never had any problems.
The default of the echo argument is true for wp_get_archives(). I think this would fix it: // One Recent Post function most_recent_post_shortcode() { return wp_get_archives( ‘type=postbypost&limit=1&format=custom&echo=0’); } add_shortcode( ‘recent-post’, ‘most_recent_post_shortcode’ ); UPDATE: Previously: echo=false Now: echo=0
There may be a more graceful way to do this, but it works: function shortcode_youtube($atts) { extract(shortcode_atts(array( “id” => ”, “align” => ‘aligncenter’ ), $atts)); global $wp_embed; $content=”‘; $embed = $wp_embed->run_shortcode( $content ); return ‘<div class=”‘.$align.'”>’ . $embed . ‘</div>’; } add_shortcode(“youtube”, “shortcode_youtube”);
Is the $my_id variable supposed to come from an attribute on the shortcode? E.g. [chapter my_id=”123″]Lorum ipsum…[/chapter] If so, at the beginning of your chapters() function, you need to retrieve the attributes out of the array being passed in. Something like: extract( shortcode_atts( array( ‘foo’ => ‘something’, ‘bar’ => ‘something else’, ), $atts ) ); … Read more
Okay so I spit through some existing themes I have to try and figure out how to achieve this. If anyone is reading this, this is how I did it: In the onclick function of the TinyMCE I called the ajax form and then inside the form I added some javascript that uses the tinyMCE.activeEditor.execCommand(‘mceInsertContent’, … Read more
Few remarks about your code: 1) First you should use something like: https://www.youtube.com/v/EhWopzlRwZ8 instead of the YouTube page: https://www.youtube.com/watch?v=EhWopzlRwZ8 in your embed code. 2) You can always use the 3) You should consider adding a prefix to your shortcode callback, for example macko_tarana_ to avoid function name collision with other plugins. 4) Try to avoid … Read more
As TomJNowell implies, you would achieve this by integrating the Feedburner API with the WordPress Shortcode API in a plugin. However, the Feedburner APIs have been shutdown since October 20, 2012 and this is no longer possible. As Google continues to deprecate support for Feedburner, your best course of action is to pursue alternatives to … Read more
The basics of creating a shortcode are quite simple. You just need to create a function that returns the code you want to output in a string and register that function: function wpse_143641_homebox_shortcode( $atts ) { return <<<HOMEBOX <div class=”homebx01 clearfix ani-1″> <div class=”homebxhead clearfix”> <div class=”bxicon homebxicon01″></div> <div class=”bxheadtxt”>Category name</strong></div> </div> <div class=”cl”></div> <div … Read more