Forums

how do i dynamically add a div + class to all entries (7 posts)

  1. sergibosch
    Member
    Posted 1 year ago #

    currently, i'm having my content editors wrap the content in every page entry with a <div class="legal"></div>

    how do code things so the editors will not have to type <div class="legal"></div> on every page entry?

  2. Rev. Voodoo
    Volunteer Moderator
    Posted 1 year ago #

    Edit page.php if its for pages, and add it where you want it.... most likely before and after the_content

  3. sergibosch
    Member
    Posted 1 year ago #

    Let's drill a bit deeper into this concept if you will. (btw, thanks Rev Voodoo for your earlier reply)

    What if I want to add a class to an <ul> (or any html content for that matter) that appears in the_content

    Do I need to write a php function or variable to do so?

    thanks!

  4. supervee
    Member
    Posted 1 year ago #

    If you don't need a different class for each

      .. you can just style it in your css

      eg:
      div.legal ul { your style here }

  5. sergibosch
    Member
    Posted 1 year ago #

    hi, supervee

    yeah, i'm comfortable using css, particularly pseudo selectors, to target the content. and i'm pretty comfortable using jQuery to add a dynamic class.

    i'm really stumped on how to add a class using PHP though.

  6. supervee
    Member
    Posted 1 year ago #

    I guess my question is .. why do you need to do this?

  7. sergibosch
    Member
    Posted 1 year ago #

    Hi, supervee

    the designers made a design that includes a scrolling div nested amongst other divs. it could appear at any point during the_content.

    to make the div scroll, i attach a class to that div, which is associated to a jQuery plugin (jScrollPane).

    i don't have the option of asking the copy editors to add a class to a div. (forget the ul i referred to earlier, it needs to be a div).

    hopefully somebody will see this that knows how to pull it off using PHP.

    thanks anyway, supervee. i appreciate your interest in the problem.

Topic Closed

This topic has been closed to new replies.

About this Topic