How to Multi-paragraph List Items?
-
I am transferring a static website of several hundred pages from a Windows host to WordPress. Most of my pages have ordered lists with individual list items that can run to several hundred, even a thousand or more, words in length. I would like to break these lengthy list items into paragraphs to improve readability while maintaining the numbering.
A typical page of this type may be found here.
My problem is that I can’t figure out how to break a list item into multiple paragraphs in WordPress. The WordPress editor strips out any
<p>
or<br>
tags or blank lines inside a list when the file is saved.For example, if I write this inside a list item:
<li> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 3</p> </li>
WP turns it into this:
<li>Paragraph1Paragraph2Paragraph3</li>
This question has been asked before in this forum, but there has never been a solution posted.
Help!!
-
Why not remove the
<li>
tags?[Moderator Note: Please post markup between backticks or use the code button.]
In HTML, there are restrictions on nested elements.
<p>
in not proper in an<li>
.Also, your ref. doc. has no
<li>
‘s.Are you suggesting that I remove the paragraph tags?
If I remove the paragraph tags, I get the same result.
Regardless of how many blank lines I insert or how many
<p>
or<br>
tags I insert or don’t insert, or how many carriage returns I insert, they are all stripped out by the WP editor and the text becomes one giant paragraph.Oh, I see. The list items are essential elements of the page. Please look at the example link I posted. Scroll to the bottom to see some multi-paragraph list items.
No I’m suggesting exactly what I said, remove the list tags. Is there a reason you need the paragraphs in a list?
Please read the link I posted.
Each webpage is the biography of a person. The person’s children are the list, with each person numbered in birth order. This is quite standard in genealogy, and I would hate to abandon the accepted convention simply to accommodate some weirdness of the WP editor.
I did a quick test with an install and I was able to do what you said but only when I used the text tab in the editor. The code was stripped out when I clicked the visual tab. I was able to use Chrome dev tools and view the post on the front end and I was able to have paragraphs within lists as long as I never hit the visual tab.
Maybe others can talk about why this may be happening.
Try enclosing the content of the li tags in a div
<ol> <li> <div> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 3</p> </div> </li> <li> <div> <p>Paragraph 1</p> <p>Paragraph 2</p> <p>Paragraph 3</p> </div> </li> </ol>
graphical_force, the paragraphs get stripped out when I save the file. When I reopen it, the paragraphs will be gone.
I can save them and view them again. What version of wp are you using? Also I’m using the Twenty Thirteen theme.
graphical_force:
Using WP 3.7.1 and also 2012 theme. I believe I am up to date. Here’s a page that I’ve been struggling with all day long.cubecolor:
Voila! I have thousands of list items, so it will be a pain to do this for every list item, but a quick test looks like it does solve the problem. Thanks!Thousands? ouch!
Adding this filter to the functions.php may help (it may not, but probably worth a try) – best if you’re using a child theme, or a functionality plugin to prevent it being overwritted on updating the theme.
remove_filter ('the_content', 'wpautop');
Again, they are not what is referred to as list items which is the HTML element li. Review your source code.
Thanks. About 6,000 list items when all pages are finished.
I’ll try the wpautop conversion you suggested in my child theme. Thanks again.
Again, they are not what is referred to as list items which is the HTML element li. Review your source code.
I have no idea what you are telling me. What do you call the numbered paragraphs in an ordered list?
- The topic ‘How to Multi-paragraph List Items?’ is closed to new replies.