• Lots of people have this issue, but as yet no solution has worked for me.

    Post has <p> tags in 2011 Theme. Post looks right in editor. When saved it loses all tags and becomes a single paragraph.

    single.php has this code

    <div class="blog-post-text">
     <?php the_content(); ?>
    </div>

    Site is https://admirephotography.com/2012/08/test-post-2/
    plugins are deactivated.

    I’d really like to get this working, rather than try to find a new theme. Finding this one took a while! Any ideas?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter SyCo123

    (@syco123)

    OK so I hacked part of the codex

    added
    content=nl2br($content);
    to wp-includes/post-template.php function the_content() before returning the output.

    That will do for now but would rather not be hacking and slashing the wordpress codebase. :/ any ideas what the proper fix would be?

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    That will do for now but would rather not be hacking and slashing the wordpress codebase. :/ any ideas what the proper fix would be?

    Noo, never modify a core WordPress file! Ever! It’s always a bad idea. Very bad things happen every time you hack the core.

    Post has <p> tags in 2011 Theme. Post looks right in editor. When saved it loses all tags and becomes a single paragraph.

    Can you better explain what you are trying to accomplish? Are you using the Visual Editor or the HTML editor?

    The function the_content() is filterable so you don’t need to modify any core WordPress file, just adjust it with a small plugin.

    <?php
    /*
    Plugin Name: nl2br the_content
    Description: Apply nl2br() to the_content.
    Version: 0.1
    */
    add_filter( 'the_content' , 'mh_nl2br_it' );
    function mh_nl2br_it( $content ) {
            return nl2br( $content );
    }

    Copy that to wp-content/plugins as nl2br-it.php and activate it and you’ll be filtering the_content()

    But again, what are you trying to accomplish…? I’m not sure why this would be necessary.

    For wordpress editor, did you edit it in Visual mode or HTML mode?

    In Visual mode, if you click “enter”, a <p></p> will be added. In HTML mode, if you click “enter”, a
    will be added. You can’t see these html tags in the wordpress editor. But they will be added when showing on frontend.

    Thread Starter SyCo123

    (@syco123)

    codingpet.com thanks for the reply. The tags are working fine in the theme 2011, the one that came with WordPress. In the Widely theme they are not. As the <p> tags are not saved with the content to the database I’m assuming at some point during the output the hidden \n character is converted to paragraphs tags. One theme is doing this fine, the theme I want to use is not. So editing in visual had no effect. I’ve hacked the code to make it work for now, so you can see paragraphs. When I originally posted the text showed as a single paragraph.

    Jan, lol. I know, I know, hacking the codebase is a terrible idea, but it worked for now. Thanks for showing me a better way. I’ll see if I can do it the way you suggest.

    One question. with the new plugin survive WordPress and theme updates in that location?

    All I’m trying to accomplish is entering text in the normal way through the visual editor. When I hit return, a new paragraph shows in the visual editor. It saves that way and shows in the editor when I reopen the page to edit. However when I view the article on the front end, the <p> tags show in Theme 2011, but they don’t show in widely.

    Really I’d like to track down the bug and squash it rather than workaround with a plugin. But I can’t spend half my life on this either. I chose WordPress to save me from having to code this myself and devote more time to running my photography business. If I wanted to code all day, I’d still be a programmer!

    As someone who spent years helping out on PHP and photography boards, I truly appreciate your attention to this thread. WordPress isn’t my thing. ??

    Thread Starter SyCo123

    (@syco123)

    Jan, thanks that’s having the same effect as not hacking the core! Handy workaround, still would prefer to fix though.

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    One question. with the new plugin survive WordPress and theme updates in that location?

    Yes. WordPress upgrades don’t delete things not related to it (included files) and that small plugin is definitely not part of the WordPress files.

    Jan, thanks that’s having the same effect as not hacking the core!

    Your welcome, just avoid modifying the core files in the future. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Widely theme has no paragraphs in post’ is closed to new replies.