I am developing a new Wordpress theme and I must permit the user to place a divider among sentences or images he/she's entering, for any publish/page.

I would like the output to become something similar to:

<div class="divider"></div>

But I'm not going the consumer to need to enter HTML within the WYSIWYG editor. Can you really request these to enter something similar to:

<-- break -->

after which translate that towards the div markup displayed?


Develop a function inside your theme's functions.php file such as this:

function add_div( $content ) {

   $content = str_replace( '<!-- break -->', '<div class="divider"></div>', $content );
   return $content;


adding the next towards the theme:

add_filter( "the_content", "add_div" );

The function uses PHP's string replace function to obtain the text you would like your customers to input and change it using the text you need to render, the add_filter() function uses Wordpress's content filter to use your function towards the content of every publish after it's read in the database, but prior to it being made towards the browser.

This works in PHP4 or more, which remains the official degree of support for Wordpress.