Stop auto formatting in shortcodes

You can postpone the wp_autop filter which is responsible for wrapping elements in P tags till after shortcodes are rendered: remove_filter( ‘the_content’, ‘wpautop’ ); add_filter( ‘the_content’, ‘wpautop’ , 12);

Remove action from shortcode

I do not want to removing and re-adding shortcode, because there is huge function beyond it. This might not answer your question, but the size of the shortcode function itself does not make much of a difference for removing and re-adding. Short or long functions take the same time here. So don’t hinder yourself removing … Read more

Caption shortcodes not including caption as attribute

Find the line /* Remove in-line styling in function.php. Comment out: /* add_shortcode(‘wp_caption’, ‘fixed_img_caption_shortcode’); add_shortcode(‘caption’, ‘fixed_img_caption_shortcode’); function fixed_img_caption_shortcode($attr, $content = null) { // Allow plugins/themes to override the default caption template. $output = apply_filters(‘img_caption_shortcode’, ”, $attr, $content); if ( $output != ” ) return $output; extract(shortcode_atts(array( ‘id’=> ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ … Read more

Check if post has gallery images/media

No Need for SQL queries in the template. function wpse_72594_get_attachments( $id, $mime=”” ) { $args = array( ‘post_type’ => ‘attachment’, ‘post_mime_type’ => $mime, ‘post_parent’ => $id ); $attachments = get_posts($args); if ($attachments) return $attachments; return false; } Then call the function like this (300 is the post ID): wpse_72594_get_attachments(300), grabs all attachments wpse_72594_get_attachments(300, ‘image’ ), … Read more

shortcode_atts – one URL variable not working

First of all, you’re using extract / shortcode_atts in correctly: The line: extract(shortcode_atts(array( “li” => get_option(‘li’), ), $liatts)); uses shortcode_atts and then extracts turns each key in the returnarray into its own variable: e.g. $li in this example. But you then go onto use $liatts anyway – which is just the attributes passed from the … Read more

Storing Options in a Shortcode

If you want to alter display based on admin options, you don’t need to deal at all with the shortcode_atts ar the $attributes that are passed into your callback. The attributes passed in (and set by shortcode_atts) are meant to alter the way a shortcode works based on how an end-user uses it. Take this: … Read more

How to get gallery id inserted to a post?

In single.php i put this code, from this link (thank you Wyck) https://stackoverflow.com/questions/14277794/wordpress-3-5-own-gallery-with-included-images-doesnt-work preg_match(‘/\/’, $post_content, $ids); $array_id = explode(“,”, $ids[1]); print_r($array_id); Now I can use gallery shortcode