1

On this page, http://www.sandfordparkslido.org.uk/events-5/ and others. I created a custom field, with advanced custom fields, so that the user can fill the content of the sidebar themselves without leaving the wordpress page they are working on.

The content of the sidebar is then pulled in with <?php the_field("sidebar_content"); ?>.

This works fine, however, I am getting some paragraph tags at the start and end of the code? This makes everything sit out of place ever so slightly, hence I want to get rid of them?

Question is, where are they coming from, so that I can delete them?

enter image description here

0

The problem is with WordPress's wpautop() filter. Here's what ACF says to do: https://support.advancedcustomfields.com/forums/topic/removing-paragraph-tags-from-wysiwyg-fields/

This is a normal WP behaviour – to turn all new lines into paragraph tags.

To remove this, you can try loading the value without any formatting. You can do this by providing a ‘false’ for the format parameter in the get_field / the_field funcions like so:

the_field('wysiwyg_field', false, false);

Hope that helps.

So just change your line to:

<?php the_field("sidebar_content", false, false); ?>

Update: I see further down in that thread they actually say you can just remove the filter with this line:

remove_filter ('acf_the_content', 'wpautop');

  • Hi, thanks, add, remove_filter ('acf_the_content', 'wpautop'); to function.php? – Grant Smith Aug 3 '16 at 16:12
  • 1
    Hmm, I've tried both and all suggestions, neither seem to work. Even though I agree they should. – Grant Smith Aug 3 '16 at 16:42
  • Maybe try adding a priority > 10? remove_filter ('acf_the_content', 'wpautop', 20); Also if you're using a dynamic sidebar, the widget might have an option for auto-formatting. – Megan Aug 3 '16 at 18:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.