• Hello folks,

    I’ve abandoned Movable Type for WordPress. Thrilled with it so far, but there’s a key difference that’s left me frustrated.

    On my old blog, every paragraph of every entry was surrounded by p tags. You know:

    <p>This is a paragraph.</p>

    This lets me separate paragraphs so they don’t look like one big wall of text.

    But when I exported the entries, the tags didn’t follow — in fact, the text file had no tags at all.

    And when I imported them into WordPress, I got nothing but br tags at the end of grafs. Like this:

    This is a paragraph<br />

    Since br tags can’t be styled, I have a blog that looks like a typewriter is melting down my screen.

    Here’s what it looks like. (Note that I added p tags to the first post to show what I’d like it to look like.)

    So my question: Is there a way I can get WordPress to manually insert p tags on these older posts? According to the forums there’s something called wpautop, but I have very little knowledge of PHP and can’t tell where I would insert this code or what I would instruct it to do.

    Any help much appreciated. Thanks, Norlos.

Viewing 14 replies - 1 through 14 (of 14 total)
  • I can see <p></p> tags on your home page…

    Just FYI, within the WordPress editor (Visual mode and HTML mode), all hard returns (manual line breaks) will be converted to br tags when displayed on the site, and all double hard returns (two consecutive manual line breaks) will be converted into paragraph tags.

    Therefore, even though you may not see p tags in the editor, as long as there are two line breaks between the first item and the next item, each will be wrapped in a p tag when displayed.

    That’s what the wpautop() function does.

    Therefore, if you just go into the editor and modify the pages, you can just add an extra line break everywhere you want to convert a br tag to p.

    You could theoretically do this kind of thing systematically (by performing a search and replace looking for all line breaks and replacing them with 2 line breaks in the database).

    Thread Starter Norlos

    (@norlos)

    Esmi,

    Thanks for looking. The problem isn’t lack of p tags altogether. The problem is they’re missing in old posts I imported from Movable Type, where they HAD been nestled in p tags. Example:

    <p>In case you missed it, the Giants blew a 21-point fourth quarter lead and lost as time expired.  To commemorate a game that is already being called the new Miracle at the Meadowlands, the New York Post offered up this classic back page:<br />
    <img src="https://gothamist.com/upload/2010/12/2010_12_gi6.jpg"><br />
    While it’s hilarious, it also marks the first time that I can recall seeing an obviously photoshopped image in print.</p>

    (in MT, the br tag separating the two grafs had been a p tag. Now, in WP, it looks like one single block of text)

    Curtiss,

    Thanks also. There an automated way I can do what you suggest? Going through nine years of posts is not my idea of a good time.

    And bear in mind the posts USED to have double returns. MT converted them to p tags. The import process stripped out ALL tags, so WP doesn’t see two returns and just gives me an insufficient br tag.

    If there’s a way to do the importing again so that I get p tags, I’d be tempted to scratch the WP installation and start anew.

    By the way, I downloaded wpautop control and turned it on. It may work for new posts, but it doesn’t seem to help for old ones.

    Thanks, Norlos.

    A link to a page demonstrating this problem might help…

    Thread Starter Norlos

    (@norlos)

    Here ya go, esmi. I’d love paragraph breaks. I could enter them manually, but I have 4,000+ posts that have been stripped of tags in the switch from MT to WP.

    Oh boy! That is going to be so difficult to fix. There’s a Search & Replace plugin that you might be able to try but it’s going to be so hard to replace just those specific <br /> tags.

    You said you imported your site from Movable Type, right? Have you done a huge amount of work since performing the import? If not, you might be able to reset your WordPress installation (delete all of the posts/pages and then empty the trash), then modify the export file itself to replace all of the br tags and/or replace all single line breaks with double line breaks; then try importing the information into WordPress again.

    this should be corrected at the database level but, how is it that words which should be capitalized at the beginning of a sentence or <p> are not?

    Thread Starter Norlos

    (@norlos)

    Meta:

    Not sure which post you mean, but I’m guessing it’s because some of my authors have a less-than-rigorous approach to standard rules of grammar.

    Curtiss:

    I wouldn’t be pleased, but I’m sure I could export my theme, delete the build and start over. The hard part is figuring out how to go through text editor and add the tags to begin with. Here’s how the export file looks:

    [Code moderated as per the Forum Rules. Please use the pastebin]

    (Note the lack of br tags, p tags, all tags really)

    Actually, as I look at that, I see a “Convert breaks” options in he header. Intriguing. I will go back to my MT build and investigate.

    Thread Starter Norlos

    (@norlos)

    OK, I think I’m close to the answer, but every time I get closer something else comes along that reminds me of my newbie status.

    Adding the phrase “line breaks” to my searches didn’t help when added to searches on the WP forum, but on Google it turns up this post and this post, and this addresses exactly my problem. So, encouraged, I deleted my installation and started anew.

    The solution is as follows:

    When I imported my entries, I was puzzled to see that where there were supposed to be two line breaks denoting a new paragraph, there was only one line break. This made my blog messy and hard to read. After some research, I learned this was happening because I had written my Movable Type entries with the Format drop-down set to “Convert link breaks.” When the entries were imported, WordPress did not translate this formatting correctly.
    
    Luckily, there is an easy fix that I found on the site On a Lark. Open up wp-admin/import/mt.php and replace this line:
    
        // Processing multi-line field, check context.
    
        if( !empty($line) )
        $line .= “\n”;
    
    with this:
    
        // Processing multi-line field, check context.
    
        if( !empty($line) )
        $line .= “\n\n”;
    
    After I changed the importer, I deleted my WordPress installation and reinstalled it since this was faster than deleting all the poorly formatted entries and comments. I then uploaded the modified mt.php and imported my entries with the correct formatting.

    But now the problem — apparently, in one of the updates to WP over the past year, the MT.php file HAS DISAPPEARED. It’s now all one file, apparently. And worse, the line of code I need to tweak is no longer in this file.

    So I have a line I can insert, but I have no idea where to insert it or what to do next.

    So the plaintive cry: Help?

    Thanks, Norlos.

    The Movable Type importer is no longer included in the core of WordPress. Instead, it has been turned into a core plugin. From the backend of WordPress, the change is hardly noticeable (when you go to Tools -> Import, you now have to install the importer rather than just using it). However, when digging through the source, it does make a difference.

    When you install the importer, it should create a new directory in wp-content/plugins called “movabletype-importer” (I believe). The file you need to modify is found inside that folder, and should be called movabletype-importer.php.

    The block of code you should be replacing is found within that file. In the current version of the plugin, it is found on line 453, and looks like:

    // Processing multi-line field, check context.
    
    				if( !empty($line) )
    					$line .= "\n";

    Basically, you just need to modify line 456, adding an additional \n to the first \n.

    Since I haven’t used this importer, I can’t say for sure that that will work, but it looks like it matches the instructions you found.

    Thread Starter Norlos

    (@norlos)

    Thanks. Yes, this all worked. That import file was the final missing piece.

    My blog now has glorious p tags throughout.

    Thanks everyone for help.

    Awesome. Glad you were able to get it sorted.

    I tried this approach and it simply added a hard line break but my paragraph still appears as one gigantic paragraph. No <p> tags. No line breaks. It seems to need actual tags in order to work. How would I accomplish that?

    Here’s an example post with no <p> or
    tags.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘I'd like to insert p tags’ is closed to new replies.