Featured image shortcode

Register the shortcode, ideally in a plugin or functions.php if you have to. add_shortcode(‘thumbnail’, ‘thumbnail_in_content’); function thumbnail_in_content($atts) { global $post; return get_the_post_thumbnail($post->ID); } Add the shortcode to you post content. [thumbnail] If you want more features, see this post or the pastebin. ADDING CAPTIONS AND LINKS add_shortcode(‘thumbnail’, ‘thumbnail_with_caption_shortcode’); function thumbnail_with_caption_shortcode($atts) { global $post; // Image … Read more

Get shortcode name from within it’s callback function? [duplicate]

The shortcode’s name is referred to as the tag. The tag is actually the 3rd (and last) parameter passed to the shortcode’s callback function. So your callback should look something like this: function print_shortcode($atts, $content, $tag) { // $atts – array of attributes passed from shortcode // $content – content between shortcodes that have enclosing … Read more

Get first video from the post (both embed and video shortcodes)

You could try mashing all the patterns together in one big regexp or and then doing a simple line by line parse of the content: function theme_oembed_videos() { global $post; if ( $post && $post->post_content ) { global $shortcode_tags; // Make a copy of global shortcode tags – we’ll temporarily overwrite it. $theme_shortcode_tags = $shortcode_tags; … Read more

How to have different captions for same image, for galleries?

Say you have image foo.jpg and bar.jpg in your media library. foo.jpg has caption saying “foo”, and bar.jpg has caption saying “bar”. Create a gallery with those two images, they will show with “foo” and “bar” captions. Want to use them again with a different caption, but using a gallery? No problem. Make another gallery … Read more

How to add multiple buttons to TinyMCE?

First add your additional buttons inside the buttons callback.. function register_button($buttons) { array_push($buttons, “quote”,”wpse-rules”); return $buttons; } Then add additional buttons function inside the plugin javascript.. init : function(ed, url) { ed.addButton(‘quote’, { title : ‘Add a Quote’, image : url+’/image.png’, onclick : function() { ed.selection.setContent(‘[quote]’ + ed.selection.getContent() + ‘[/quote]’); } }); ed.addButton(‘wpse-rules’, { title … Read more