Category: PHP Codes.

This post will be first of many articles I will share with you on WordPress tips and tricks that I have learned over the years, sometimes pulling information from other WordPress resource sites…one of the biggest resource sites being WordPress.org.

So here is your first WordPress tip from Your Digital Marketing Maven…

Have you ever wanted to add a simple dividing line or divider line in your blog posts or pages? There’s any easy solution to this and it just takes a couple of coding changes in your WordPress theme function file and your theme’s CSS stylesheet. Depending on what WordPress theme you use, it may already have the ability to automatically add dividing lines in posts and pages, but if it does not, then you have an alternate way of adding lines in.

Step One:

Adding the following PHP code to your theme’s “functions.php” file, at the bottom of the page, right before the “?>” symbol*:

add_shortcode( ‘divider’, ‘shortcode_insert_divider’ );
function shortcode_insert_divider( ) {
return ‘<div class=”divider”></div>’;
}

*You can find the functions.php file in your WP dashboard…Appearance/Editor/Theme Functions file. In most cases, the file is named “functions.php”.

Step Two:

Adding the following CSS style code to the bottom of your theme’s “style.css” file (again, located in the Appearance/Editor window):

.divider {
width: 90%;
margin: 15px auto;
height: 1px;
background-color: #999;
}

Keep in mind that you can change the CSS styling above to suit the look and feel of your own WordPress theme.

Step Three:

When you are in your post or page editor window, either before or after your content, add the following shortcode statement:

You can add the “divider” shortcode anywhere in your post and page.

Below is a screenshot of how the divider line would look once you have added the above function and CSS codes to your WordPress theme files:

 See how easy that was? Now go and create your own divider lines…as many as you like!

More soon!