Insert PHP code via shortcode?

$current_user isn’t declared in the scope of that function. You’d want to modify the code to be more like this: function get_form($atts) { $current_user = wp_get_current_user(); return ‘<form method=”post” action=””> <input type=”input” name=”myinput” value=””></input> <input type=”hidden” name=”myvar” value=”‘ . $current_user->ID . ‘”> </form>’; } add_shortcode(‘myshortcode’, ‘get_form’);

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