As I used to be engaged on a brand new premium WordPress theme for Themeforest I used to be having points with my Pricing Desk shortcode because it saved including further spacing attributable to stray empty paragraph (p) tags that have been being added robotically by WordPress. Doing somewhat looking out I discovered an amazing answer on the TF discussion board.
Clear Up WordPress Shortcodes Perform
Merely copy and paste the next code into your features.php file or wherever your maintain your shortcodes. This perform will clear up the output of your shortcodes, which is particularly vital for nested shortcodes.
if( !function_exists('wpex_fix_shortcodes') ) {
perform wpex_fix_shortcodes($content material){
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);
$content material = strtr($content material, $array);
return $content material;
}
add_filter('the_content', 'wpex_fix_shortcodes');
}
What it does…This piece mainly grabs all of the publish content material earlier than it’s outputted and replaces particular code as talked about under:
- All situations of <p>[ are replaced with [ – Removes opening paragraphs before shortcodes
- All instances of ]</p> are changed with ] – Removes closing p tags after shortcodes
- All situations of ]<br /> are changed with ] – Removes breaks after shortcodes