Posted Under: Blogging, Wordpress, Wordpress Hacks
WordPress is a great CMS, but implementing some features within your theme can require a little lateral thinking. The content for your page or post is usually output by the theme code using a single function call:
the_content(args);
But what if you need to split the content into two or more blocks? That might be necessary if your theme requires multiple columns or sections on the page. WordPress provides a get_the_content() function to return content as a PHP variable, but how do you determine where the divisions occur? There are a few solutions on the web, but most involve either:
- Splitting the content at HTML tags such as
h2headings. Unfortunately, that requires the content author to know a little HTML and it’s not very versatile — you couldn’t allow two headings in one column. - Using a WordPress shortcode. That’s more flexible, but it still puts the onus on the content editor to remember and use the right code.
The WordPress <!--more--> tag may offer a better solution. It’s normally used to split a long article into two or more pages, but not all themes use that facility and it only works for WordPress posts by default (not pages). Using the <!--more--> tag offers several advantages:
- A “more” toolbar button is available in both the visual and HTML editing pane.
- Divisions can be placed anywhere in the content.
- It’s easy for non-technical users to understand how the content will be split.
To split your content, locate your theme folder (wp-content/themes), edit or create a functions.php file and add the following function within a <?php … ?> block:
Last 5 posts in Blogging
- How To Add Quizzes To Your Self-Hosted Wordpress Blog - February 17th, 2010
- How to Access and Add Facebook Chat from Any Desktop IM Client - February 12th, 2010
- How to Automatically Use Resized Images Instead of Originals Using PHP Script in Wordpress - February 8th, 2010
- New Latest Free WordPress Themes Released in Feb till 4 Feb 2010 - February 4th, 2010
- See Blog Posts Around the World on a Globe as a Screensaver As soon as they are Published - August 21st, 2009


Leave a Reply