• MrShawnTierney

    (@mrshawntierney)


    Good morning all,

    tldr; I don’t want WordPress to delete extra spaces in my posts anymore

    Has anyone found a way to stop WordPress from deleting extra spaces purposely added in posts? This has been an issue going back over 10 years with ALL of my WordPress sites, including those using the default WordPress themes.

    I’m sure it is by design, but it’s one of those design decisions that doesn’t make sense to an old timer like me, so I was curious if anyone had a site wide solution (I did search around for several minutes but didn’t find anything.)

    Note that I can add them in the classic editor text mode, but as soon as I switch to visual they all get deleted.

    Here’s an example:
    One Space before
    Two Spaces before
    Three Space before
    Four Spaces before
    —–Five Dashes Before

    Thanks in advance,

    Shawn

Viewing 1 replies (of 1 total)
  • ravindra107

    (@ravindra107)

    Hey @mrshawntierney,
    In the Classic Editor’s text mode,   may appear. Please remove it. Additionally, I will provide a filter to remove the autoformatting.

    add_filter('tiny_mce_before_init', function($init) {
    $init['remove_linebreaks'] = false;
    $init['convert_newlines_to_brs'] = false;
    $init['remove_trailing_nbsp'] = false;
    $init['entity_encoding'] = 'raw';
    return $init;
    });

    Place the above code into the functions.php file of your active WordPress theme or child theme.

    Best Regards
    Ravindra Singh Meyda

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.