Using Variables in Shortcodes

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

Forcing WP to embedd a video when using a shortcode

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”);

Custom shortcode breaks my page

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

Pass data back to TinyMCE from Thickbox

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

Youtube shortcode

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

How to display Feedburner subscription count as plain text via a shortcode in post/page editor of my WordPress blog?

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

Convert my php code into shortcode

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

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)