This article demonstrates how to divide WordPress content into multiple sections using the built-in <more></more>
tag, offering a user-friendly alternative to HTML or shortcodes. The method avoids requiring coding knowledge from content authors.
WordPress typically outputs page/post content using the_content()
. However, dividing content into blocks (for multi-column layouts, for example) necessitates a different approach. While get_the_content()
provides content as a PHP variable, identifying division points requires careful consideration. Common solutions, such as splitting at HTML tags (like <h2></h2>
headings) or using shortcodes, present limitations: HTML tag methods require content author HTML knowledge and limit flexibility, while shortcodes burden the editor with remembering specific codes.
The <more></more>
tag offers a superior solution. While often used for pagination, its advantages here include: a dedicated toolbar button in both visual and HTML editors, flexible placement within content, and ease of use for non-technical users.
To implement this, modify or create a functions.php
file within your theme folder (wp-content/themes
). Add the following PHP function:
// split content at the more tag and return an array function split_content() { global $more; $more = true; $content = preg_split('//i', get_the_content('more')); for($c = 0, $csize = count($content); $c < $csize; $c++) { $content[$c] = apply_filters('the_content', $content[$c]); } return $content; }
Next, locate the_content()
calls within your theme's loop (likely in single.php
, page.php
, and potentially index.php
, archive.php
, or search.php
). Comment out the_content()
and replace it with a call to split_content()
. This function returns an array where each element represents a content block separated by the <more></more>
tag. You can then output this HTML as needed. For example:
<?php //Example usage: (Adapt to your theme's structure) add_filter( 'the_content', 'my_custom_content' ); function my_custom_content( $content ) { return str_replace( 'Read the rest of this page »', '', $content ); } // split content into array $content = split_content(); // output first content section in column1 echo '<div>', array_shift($content), '</div>'; // output remaining content sections in column2 echo '<div>', implode($content), '</div>'; ?>
Remember to adapt this to your theme's specific structure. This approach provides a clean, user-friendly method for dividing WordPress content without complex coding or plugin dependencies.
Frequently Asked Questions (FAQs) about Splitting WordPress Content into Multiple Sections
(The FAQs section remains unchanged as it offers alternative methods and addresses common concerns related to content splitting, which is valuable supplementary information.)
The above is the detailed content of How to Split WordPress Content Into Two or More Columns. For more information, please follow other related articles on the PHP Chinese website!

WordPressexcelsoverotherwebsitebuildersduetoitsflexibility,scalability,andopen-sourcenature.1)It'saversatileCMSwithextensivecustomizationoptionsviathemesandplugins.2)Itslearningcurveissteeperbutofferspowerfulcontroloncemastered.3)Performancecanbeopti

Seven Must-Have WordPress Plugins for 2025 Website Development Building a top-tier WordPress website in 2025 demands speed, responsiveness, and scalability. Achieving this efficiently often hinges on strategic plugin selection. This article highlig

WordPresscanbeusedforvariouspurposesbeyondblogging.1)E-commerce:WithWooCommerce,itcanbecomeafullonlinestore.2)Membershipsites:PluginslikeMemberPressenableexclusivecontentareas.3)Portfoliosites:ThemeslikeAstraallowstunninglayouts.Ensuretomanageplugins

Yes,WordPressisexcellentforcreatingaportfoliowebsite.1)Itoffersnumerousportfolio-specificthemeslike'Astra'foreasycustomization.2)Pluginssuchas'Elementor'enableintuitivedesign,thoughtoomanycanslowthesite.3)SEOisenhancedwithtoolslike'YoastSEO',boosting

WordPressisadvantageousovercodingawebsitefromscratchdueto:1)easeofuseandfasterdevelopment,2)flexibilityandscalability,3)strongcommunitysupport,4)built-inSEOandmarketingtools,5)cost-effectiveness,and6)regularsecurityupdates.Thesefeaturesallowforquicke

WordPressisaCMSduetoitseaseofuse,customization,usermanagement,SEO,andcommunitysupport.1)Itsimplifiescontentmanagementwithanintuitiveinterface.2)Offersextensivecustomizationthroughthemesandplugins.3)Providesrobustuserrolesandpermissions.4)EnhancesSEOa

Enable comments on your WordPress website to provide visitors with a platform to participate in discussions and share feedback. To do this, follow these steps: Enable Comments: In the dashboard, navigate to Settings > Discussions, and select the Allow Comments check box. Create a comment form: In the editor, click Add Block and search for the Comments block to add it to the content. Custom Comment Form: Customize comment blocks by setting titles, labels, placeholders, and button text. Save changes: Click Update to save the comment box and add it to the page or article.

How to copy WordPress subsites? Steps: Create a sub-site in the main site. Cloning the sub-site in the main site. Import the clone into the target location. Update the domain name (optional). Separate plugins and themes.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Notepad++7.3.1
Easy-to-use and free code editor

Zend Studio 13.0.1
Powerful PHP integrated development environment

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Atom editor mac version download
The most popular open source editor
