• Resolved eadwig

    (@eadwig)


    Hello

    I created two post loops in my custom loop – main loop and custom post loop. In the single post page of the main loop, the text entered in the default visual text editor is displayed with correct line breaks, but in the single post page of the custom post loop, all of the line breaks are forcefully removed for some unknown reason…
    My client doesn’t resort to using an advanced text editor or HTML, so I have to find a way to stop the default text editor from removing space.

    Disabling Autop filtering introduced here made no change. I just cannot see why the default editor forces removal of space when no such setting is configured.

    Please someone out there let me know what could cause your default visual text editor to remove space from the text you enter and if possible, workarounds to prevent it happening.

    Thank you as always,

    Ead

Viewing 9 replies - 1 through 9 (of 9 total)
  • helldog2018

    (@helldog2018)

    Hi @eadwig,

    Can you send us a link to a page where it is showing correctly and a page where it is showing incorrectly? We might find difference in there. Thanks.

    Thread Starter eadwig

    (@eadwig)

    Hello helldog2018

    Thanks for the reply.
    The site has basic authentication applied and cannot be disclosed until all errors are resolved. All the same the error is simple. For example, when I type the following in the Visual mode of the default text editor:

    Lorem ipsum dolor sit amet,
    vel tantas vocent maluisset te,
    quem idque dicunt in mei.

    It is displayed in a single post page in the following format with no line breaks:

    Lorem ipsum dolor sit amet, vel tantas vocent maluisset te, quem idque dicunt in mei.

    In the other single post page, the same text shows as:

    Lorem ipsum dolor sit amet,
    vel tantas vocent maluisset te,
    quem idque dicunt in mei.

    I did not set up anything to remove space, so I have no clue how to disable it…

    helldog2018

    (@helldog2018)

    Hi @eadwig,

    You already tried disabling the autop filter, maybe try the following. Add the following code inside your functions.php

    function clear_br($content) { 
    return str_replace("<br/>","<br clear='none'/>", $content);
    } 
    add_filter('the_content','clear_br');

    If this is not working, then you might as well try to create a <br> shortcode.
    To create a shortcode fill in the following code inside functions.php

    function add_linebreak_shortcode() {
    return '<br />';
    }
    add_shortcode('br', 'add_linebreak_shortcode' );

    Now if you fill in the shortcode [br] it should enter a linebreak.
    Hope this helps a bit.

    Thread Starter eadwig

    (@eadwig)

    Hello helldog2018

    Thanks for your suggestions.

    I understood the meaning of the code and embedded the clear_br function in the functions.php with no luck. Something I noticed though was that at least Chrome shows a line break at the correct location with no <br>:

    <p class=”description”>lorem ipsum

    dolor sit<span class=”more”>Continue Reading</span></p>

    Just in case, I checked through the CSS assigned to p.description but found nothing of importance. If this indicates anything, please let me konw.

    Thank you,

    Ead

    helldog2018

    (@helldog2018)

    Hi @eadwig,

    Can you check what it does if you add an empty class?
    Just change <p class=”description”> to <p class=””> and check what it does.

    Thanks.

    Thread Starter eadwig

    (@eadwig)

    Hello helldog2018,

    I removed class=”description” and ended up with the same results as shown above.

    Still not sure what could be the cause of this…

    Ead

    helldog2018

    (@helldog2018)

    Hi @eadwig,

    If nothing helps, can you show me the single-post and custom-post php pages?
    Maybe something is wrong with the coding.

    Thanks.

    Thread Starter eadwig

    (@eadwig)

    Replacing the following line:

    echo ‘<p>’.$page_object->post_content.'</p>’;

    with the following line fixed the line-break problem:

    echo $page_object->post_content;

    Cheers,

    Ead

    • This reply was modified 6 years ago by eadwig.
    helldog2018

    (@helldog2018)

    Hi @eadwig,

    Yup removing the paragraphing does the trick. Good catch and happy it’s solved 😉

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Default Visual Text Editor Automatically Removes Line Breaks’ is closed to new replies.