How to Split WordPress Content Into Two or More Columns?
Hi friends,
I have done the PHP programming language to great extent but still there are many doubts that I am unable to resolve.!! I don't know about the splitting of WordPress content. So I thought that posting you would help me.!! So please explain me about the splitting WordPress Content into two or more columns.!! Please reply me as soon as possible. Thanks in Advance for the Help.!! :notworthy
Re: How to Split WordPress Content Into Two or More Columns?
You should know about the WordPress more clearly before moving moving into the depth. WordPress is a great CMS (Content Management System). But for implementing the features of that needs more logical thinking from your side. The content for your page or post is usually output by the theme code using a single function call, which is :
Hope that you get this basic point of the WordPress.
Re: How to Split WordPress Content Into Two or More Columns?
In many scenarios it becomes necessary to split the content into two or more blocks. For doing this you should use get_the_content() function. WordPress provides a get_the_content() function to return content as a PHP variable. You can use that function for splitting the content of the WordPress into two or more columns. To split your content, you will have to locate your theme folder. Your theme folder would be in the installed directory.
Re: How to Split WordPress Content Into Two or More Columns?
The following are the few solutions to determine where the divisions occurs when using the get_the_content() function :
- You can split the content at HTML tags such as h2 headings. But the main drawback of this is that it requires the content writer to know a little HTML and it’s not very versatile. Also you cannot allow two headings in one column.
- The other method is that you can pass it by using the WordPress shortcode. When compared this to the first option, this is more flexible.
Re: How to Split WordPress Content Into Two or More Columns?
I think that it would be better to use the WordPress <!--more--> tag. Using the <!--more--> tag offers several advantages which are as follows :
- A toolbar button called more is available in both the visual and HTML editing pane.
- You can place the divisions anywhere in the content.
- It’s easy for non-technical users to understand how the content will be split.
Re: How to Split WordPress Content Into Two or More Columns?
To split your content, you will have to locate your theme folder or if it is not existing, you can create a functions.php file and add the following function within a <?php … ?> block :
PHP Code:
function split_content() {
global $more;
$more = true;
$content = preg_split('/<span id="more-\d+"><\/span>/i', get_the_content('more'));
for($c = 0, $csize = count($content); $c < $csize; $c++) {
$content[$c] = apply_filters('the_content', $content[$c]);
}
return $content;
}