hey guys,
i really need your help.
Whenever I use a gallery in wordpress and set it’s columns to just 1 WordPress automatically adds <br style="clear: both"/>
after every <dl class="gallery-item">
. I really need to prevent this behaviour and therefore I’d like to add a filter to my functions.php
The following to examples don’t work.
add_filter( 'post_gallery', 'remove_br_gallery', 9);
function remove_br_gallery($output) {
return preg_replace('#<br*.?>#is', '', $output);
}
add_filter( 'the_content', 'remove_br_gallery', 9);
function remove_br_gallery($output) {
return preg_replace('#<br*.?>#is', '', $output);
}
Neither does this:
return str_replace('<br style="clear: both">', '', $output);
Any idea how I could solve that? I just don’t want to have any <br style="clear: both"/>
inside of my galleries.
EDIT:
you must call your filter after the shortcode is processed, giving it priority > 10, and you must match on a multiline expression.
Try this work with my installation and using the standard gallery shortag:
Or, alternatively, you could try disabling the effect of the
<br>
‘s via a stylesheet override, for instance:body dl.gallery-item + br { display: none; }
You can use Justin Tadlock’s Cleaner Gallery plugin to get clean markup.
Preg replace should contains apostrophes.