WordPress.org

Ready to get started?Download WordPress

Forums

Wrap all <p> after the first </p> in a a div? (4 posts)

  1. artfulalibi
    Member
    Posted 6 years ago #

    Hello,

    I'd like to wrap all my content after the first <p></p> in a div. Anyone have any idea how I could go about doing this?

    Thanks!

  2. Sammy Russo
    Member
    Posted 6 years ago #

    can you give us a little more information about what the end goal is?

    for most themes all the content is wrapped in a div class="post" id="post-id#".

    in every post.. WP auto wraps each paragraph with the appropriate <p></p> tags..

    with this said.. a little more inside details would help us understand why you are trying to do what you asked so we can help.

    I'll be on for another hour or so..

  3. artfulalibi
    Member
    Posted 6 years ago #

    Ya,

    I know how the data is normally wrapped. My end goal is to show the first paragraph of each post on the index, and using some nice jquery script, allow the user to expand the panel to see the full story. This requires wrapping everything after the first </p> in a <div>.

  4. studiochris
    Member
    Posted 6 years ago #

    Just let jQuery do the work. Have it find the <p> elements in all of the post divs... after the first one, insert your opening div tag and some CSS classes and then after the final one (or :before the next post div), add the closing div tag. Then you can manipulate that created div element any way you wish.

Topic Closed

This topic has been closed to new replies.

About this Topic