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);
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);
add_shortcode() may be overwritten, dependent upon at what point it is hooked, whereas you would have to remove_filter() to prevent the filter from executing. I think the way to go is to use apply_filters(), as that functionality is clearly put in place to do exactly what you’re trying to do.
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
You have to return html instead of echoing it. Buffer output withing your function and return it: function shortcode_output() { ob_start(); //get stuff from database //format stuff echo <<<FORM <form method=”POST” action=”blah.php”> <!–more html–> </form> FORM; $html = ob_get_contents(); ob_end_clean(); return $html; }
use do_shortcode($content) instead of $content in first function(collapsegroup)
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
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
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
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
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