Title: WordPress   TinyMCE : Wrap several elements in DIV
Last modified: August 31, 2016

---

# WordPress TinyMCE : Wrap several elements in DIV

 *  Resolved [meneldil](https://wordpress.org/support/users/meneldil/)
 * (@meneldil)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/)
 * I want to know if it is possible to wrap multiple items in a div with TinyMCE?(
   to apply a particular style)
    I want to avoid using a shortcode.
 * Here is my setup:
 *     ```
       $style_formats = array(
           array(
               'title' => 'Title with list',
               'block' => 'div',
               'classes' => 'my-class',
               'wrapper' => true,
           ),
       );
       ```
   
 * The result:
 *     ```
       <div class="my-class"><h3>Title</h3></div>
       <ul>
           <li>
               <div class="my-class">Some text...</div>
           </li>
           <li>
               <div class="my-class">Some text...</div>
           </li>
           <li>
               <div class="my-class">Some text...</div>
           </li>
       </ul>
       ```
   
 * But I want to have something like this:
 *     ```
       <div class="my-class">
           <h3>Title</h3>
           <ul>
               <li>Some text...</li>
               <li>Some text...</li>
               <li>Some text...</li>
           </ul>
       </div>
       ```
   
 * I wonder if this is possible.
    Thanks in advance ! 🙂

Viewing 10 replies - 1 through 10 (of 10 total)

 *  [kmessinger](https://wordpress.org/support/users/kmessinger/)
 * (@kmessinger)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170826)
 * I pasted the code into my blog and it worked fine.
 *  Thread Starter [meneldil](https://wordpress.org/support/users/meneldil/)
 * (@meneldil)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170847)
 * Are you sure?
    The div should include the title and list at once.
 * Here it wrap title and each list item.
 *  [kmessinger](https://wordpress.org/support/users/kmessinger/)
 * (@kmessinger)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170875)
 * The code above results in
    **Title**
    - Some text…
    - Some text…
    - Some text…
 *  Thread Starter [meneldil](https://wordpress.org/support/users/meneldil/)
 * (@meneldil)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170882)
 * Have you read my question?
 * I use “TinyMCE Custom Styles”:
    [https://codex.wordpress.org/TinyMCE_Custom_Styles](https://codex.wordpress.org/TinyMCE_Custom_Styles)
 *  [kmessinger](https://wordpress.org/support/users/kmessinger/)
 * (@kmessinger)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170895)
 * Sorry, all I payed attention to was “I want to know if it is possible to wrap
   multiple items in a div with TinyMCE?” and “But I want to have something like
   this:
 *     ```
       <div class="my-class">
           <h3>Title</h3>
           <ul>
               <li>Some text...</li>
               <li>Some text...</li>
               <li>Some text...</li>
           </ul>
       </div>
       ```
   
 *  and this, “The div should include the title and list at once.”
 * I will move this to a different section so you can get this resolved.
 *  Thread Starter [meneldil](https://wordpress.org/support/users/meneldil/)
 * (@meneldil)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170897)
 * No problem! 😉
    Thank you for the transfer. 🙂
 *  [ancawonka](https://wordpress.org/support/users/ancawonka/)
 * (@ancawonka)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7170917)
 * Hmm. I think you need to use a different method to do this. Based on the documentation
   here:
 * [https://www.tinymce.com/docs/configure/content-formatting/#formats](https://www.tinymce.com/docs/configure/content-formatting/#formats)
 * >  Block: Name of the block element to produce for example “h1”. Existing **block
   > elements** within the selection gets replaced with the new block element.
 * You can see this behavior if you, say, create your list and then select “Heading
   2” from the drop-down. H2’s are added to all the list items, just like your div
   is added.
 * If you create a button (like the blockquote button, for example), then you’ll
   get your HTML text enclosed in another div.
 * Take a look here:
    [https://codex.wordpress.org/TinyMCE_Custom_Buttons](https://codex.wordpress.org/TinyMCE_Custom_Buttons)
 * And Here:
    [http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons–wp-30182](http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons–wp-30182)
 * Caveat: I haven’t actually done this – I just spent some time researching it 
   a while ago for a client.
 *  Thread Starter [meneldil](https://wordpress.org/support/users/meneldil/)
 * (@meneldil)
 * [10 years, 2 months ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7171036)
 * Many thanks ancawonka!
    After slightly modified the code I have what I wanted.
   🙂
 * I also added a button to remove the div.
    Here is the method: [http://community.tinymce.com/forum/viewtopic.php?id=19973](http://community.tinymce.com/forum/viewtopic.php?id=19973)
 *  [ancawonka](https://wordpress.org/support/users/ancawonka/)
 * (@ancawonka)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7171067)
 * Ah! Thanks for posting the solution! That’s going to come in handy for someone
   soon!
 *  [smile](https://wordpress.org/support/users/soulblog/)
 * (@soulblog)
 * [10 years ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7171169)
 * That’s great. Thank for sharing!

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘WordPress TinyMCE : Wrap several elements in DIV’ is closed to new replies.

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 10 replies
 * 4 participants
 * Last reply from: [smile](https://wordpress.org/support/users/soulblog/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/wordpress-tinymce-wrap-several-elements-in-div/#post-7171169)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
