Content Parts


This plugin allows you to split your editable content into multiple parts and display each part using template tags within your theme, allowing you to create complex content layouts.

It works in a similar way to how you split your content area into multiple pages…

Splitting your content into multiple parts

The plugin adds a new button to the rich text editor.

Clicking this button will insert a break to divide your content into multiple parts. The break will be define by a dotted line and tag.

In the HTML these dividers are defined by HTML comments so they degrade seamlessly if you deactivate the plugin – they don’t display to the user.

Adding template tags to your theme

To display the content parts you will need to add some template tags to your theme. Without adding tags the content will continue to display as normal using the the_content() template tag.

The Content Parts plugin has several template tags to display your content:

  • the_content_part( $page = 1, $args = null );
  • get_the_content_part( $page = 1, $args = null );
  • the_content_parts( $args = null );
  • get_the_content_parts( $args = null );
  • has_content_parts( $args = null );
  • count_content_parts( $args = null );

Example 1

To correctly show the first content part instead of the main the_content() tag.

if ( function_exists( 'the_content_part' ) ) {
	the_content_part( 1 );
} else {

Example 2

Display the second content part. Checking that the function exists first will ensure compatibility if you deactivate the plugin.

<?php if ( function_exists( 'the_content_part' ) ) the_content_part( 2 ); ?>

Example 3

Display the third content part surrounded by a div.

<?php if ( function_exists( 'the_content_part' ) ) the_content_part( 3, array( 'before' => '<div class="content-area-3">', 'after' => '</div>' ) ); ?>

Example 4

A complex example. If there are multiple content parts, show the first content part followed by the next 3 content parts in a repeating set of styled divs. If you want to include all remaining content parts in the list, omit the ‘limit’ parameter.

if ( function_exists( 'the_content_part' ) && has_content_parts() ) {
	the_content_part( 1, '<div class="header">', '</div>' );
	the_content_parts( array(
		'before' => '<div class="item">',
		'after' => '</div>',
		'start' => 2,
		'limit' => 3
	) );
} else {


Top Downloaded Mp3s
best dentist in los angeles
best web host
web hosting
vps hosting

61 thoughts on “Content Parts

  1. Hi !
    Thanks for this plugin !

    But it does not work properly!
    In the loop, it only displays the contents of the first section and applied to others. This bug is a simple bug or it’s my loop ?

    Thanks ! :)

  2. So your seeing the first content part, but what do you mean “applied to others”?

    Have you added code into your theme to show the second part at all?

    < ?php if ( function_exists( 'the_content_part' ) ) the_content_part( 2 ); ?>
  3. Valentin, is that an archive or category page? I’ve only tested it fully on single posts and pages at the moment.

    …or have you created a custom loop – if so how did you create your custom loop?

  4. Hi

    This is a great idea for a plugin and I really like the way it’s done, but I’ve come across one problem: I’m putting a h1 or h2 header as the first line of each content part, but they are getting stripped out when the content parts are displayed.

    It seems to be because the opening h1 or h2 tag ends up being before the divider somehow.

    Not sure if this is an easy issue to sort out, as it’s caused by the TinyMCE editor more than your plugin I think?

  5. Simon,

    The Content part divider really needs to be on it’s own line in the editor. If it appears to be be included within a header tag, simply put an extra return in between the divider and the heading – that should sort it.

    – Ben

  6. Great plugin – Well done!

    I’ve been adding such functionality to a couple of themes, but having a icon on the editor to press when you need to is really great.

    Thanks for sharing this great work of yours.

  7. Roy, no plans as yet. My next priority is to get it to work with paging functionality. Named parts would add an additional complexity to how you would manage this via the editor – if you have any thought please post them here…

  8. hey ben,

    nice plugin! i’ve tried it on an archive page (which is where i could use it) but makes some problem. it takes the content part from the last post and puts it on all posts in the archive. any clue how to fix this?


  9. i mainly post movies with a discription on the side. when i list the posts in a category i would like to show a part of the post with a small preview image for each post. maybe i could include that in the post as a part…

  10. i was thinking for a split Post function in wordpress to split my big post into pieces and to update them, Your Code has saved lots of work of mine. I can quickly edit it and make the modification required for my work. Thanks for the awesome Job

  11. hi,
    i created my own loop and then the plugin doesn’t work.
    my loop looks like this:

    $recentPosts = new WP_Query( );

    while ($recentPosts->have_posts()) : $recentPosts->the_post();

    works but not the
    the_content_part( 1 );
    can u help me please?

    thank you

  12. like to use the tag instead of the ‘more’ tag because as th3dark mentioned above the ‘more’ tag is usually used to show only a part of the content of a post or page.

    If you install the TinyMCE Advanced plugin you can add the “Split Page” icon to your editor (which looks very like the More Tag button) to easily insert these breaks. You’re unlikely to want to split a page into separate pages and have multiple content areas in the same template so this works quite well.

  13. Hiya, nice plugin.. but having trouble with custom post types and the_content_part() function. Nothing comes out, though it loops through my own:

    foreach ( $content_parts as $page ) {


    Any ideas on how to make this work with my custom post type?


  14. @Aleks Can you confirm wether there is anything in the $content_parts variable when you loop though it?

    If not you need to make sure you are using it in the WordPress Loop. ie after the the_post() function in your template.

  15. Here’s the kind of code i am using… granted my loop through the content parts as $page is maybe not quite right… but not even the first call to the_content_part(1, ”, ”) returns anything… the if has skips to the_content() …. so somehow its not seeing the function totally.. no php errors… thats why i think its custom post… functions dont error but return nothing.

    $pagenumber = 0;
    $globalpagenumber = 0;
    query_posts( 'post_type=book&child_of=' . $id . '&order=ASC' );
    if ( have_posts() ) : while ( have_posts() ) : the_post();
    	<section class="title- page-  globalPage-" style="z-index: 499; ">
    		<a href="">:</a>
    			'post_type' => 'book'
    		) );
    } else {
    <section class="title- page- globalPage-" style="z-index: 499; ">
    	<a href="">
  16. What a nice Plugin! But is it possible to set a custom Name to the dividers


    divider1 = “Main Content”
    divider2 = “Header Section”
    divider3 = “Section in Sidebar 1”
    divider4 = “Section in Sidebar 2”
    divider5 = “Footer Section”

    i need this be because some Posts use only the Header Section, some use only Sidebar 1 & Sidebar 2, some use Footer Section & Sidebar2 ….

    it will be great to see this in the next future


  17. Hi – this looks ace; thanks very much.

    Is there a way to check how many parts there are? I’m looking to give each div a different class (probably something like, ‘item-1’, ‘item-2’ etc.) – and would need the number I think, somehow.

    I imagine this is probably related to Stephan’s question above, but I remain hopeful!


  18. Hi, thanks for the reply,
    I’ve tried the code above but it always return the contents of the current post not the content of $my_page_id.
    I’m trying to add a content part from another page into a new page.

  19. Hi.
    Your ‘content parts’ is a nice plugin.
    but it does not work inside the loop.
    Or i mistake.
    when i use this code inside the loop ( loop-search.php in this example ) :

    if ( function_exists( ‘the_content_part’ ) ) {
    the_content_part( 2 );
    } else {

    and it outputs just the content of first result for all posts in the result !!
    is there any way to solve this problem?

  20. Hi again mr Ben Huson.
    Yes the 1.4 solved problem :D
    very nice.
    And it seems there is another problem or i am mistaking.
    the problem is that i’ve two themes on my wordpress site.
    on the first theme that i have used the code to load custom part of the content, it works correctly,
    but on the second template it loads just the first (1) part of content.
    is this problem is true or it’s a mistake from me.
    and the last question i have is :
    can i use this nice plugin to return the custom part into a variable? does get_the_content_part function work like the wordpress default tag get_the_content?
    Thank you very much.

  21. Hello Ben,

    Everything is working fine..
    but the problem is in Search:
    wen search the page showing results with “content 1st part” and ” –>” ..

    it should only show the title link.
    Please Help me..
    Thank you very much !

  22. I was hoping this plugin would fit my needs. Unfortunately it’s not fool proof enough to divide the content into separate wordpress textarea boxes.

    I’d pay fair money to get the functionality that has in parts in WordPress.

  23. Hi Ben,

    I’m using “Sliding Door” (in the WordPress by Wayne Connor) as my current theme. Each sliding door assigned to one of my seven categories.

    I also like to have seven parts ( from top to down, accordingly to above 7 sliding doors/categories) in main content of my Home page and each part will display the links of 5 latest posts in the specific category).

    Can I use your plug-in to serve this purpose? Or your plug-in is just adding dividers between displayed posts?

    Thank you in advance.

  24. @arkitect This plugin does more than adding just divider lines. It allows you to add template tags into your theme files to display the different sections of editable content in different places in your template.

    If you are displaying your latest links by entering them into the editable content area either manually or via a shortcode, then you could use this plugin to split the content area into section to display them in a certain way in your templates.

    If you are displaying the latest links using code in your theme templates this plugin will not be of any help.

  25. Hello Ben

    It’s a REALLY nice plugin you made. I’m currently testing it and it works just great except for one thing. I’ve turned an HTML template into Wordpress theme and when I use content parts somehow an entire row is added below each content-part block, which messes up my layout because everything is being pushed down.

    As I was using the ‘surrounded by a div’ code from example 3 of your instruction above I thought the reason for that extra line was precisely that PHP-generated div container. So I switched to the code from example 2 (no div container there) and … nothing has changed. I mean, the extra row is still there.

    I noticed that when I edit Wordpress template and type the desired text the extra row disappears. But when I put back the content-part code the extra row comes back again.

    Two examples from my index.php file, both display the very same text, that is ‘Welcome’

    Welcome – no extra row displayed in a browser

    – extra row appears

    Any suggestions? I hope it’s just me doing something wrong, ’cause the plugin is just way too promising.

  26. Oops, I see my two examples got stripped of tags so you won’t understand what I meant. Let me try again (h1 below is of course html header tag)

    h1 Welcome /h1 – no extra row displayed in a browser

    h1 code_from_example_2_above /h1 – extra row appears

  27. @Radek By default it applies the WordPress the_content filter on the output which means it is probably wrapping P tags around the content before yu put your H1 around it. Can you check?

  28. You’re right Ben, this is exactly what happens. Here’s how I got rid of the P tags:

    1. I put the content into a variable like that:
    variable = get_the_content_ part

    2. Used a PHP function to remove the P tags:
    echo strip_tags (variable)

    It works, though there might be a more gracious way of doing it.

    Anyway, thanks for help Ben.

  29. Hi Ben,

    Thanks for the plugin work. I have found an issue on line 68 of content-parts.php. You are checking strpos() against integer, instead of against boolean, therefore throwing false negative if strpos is == 0.

    Currently reads:

    if ( strpos( $content, ‘‘ ) ) {

    Should read:

    if ( strpos( $content, ‘‘ ) !== false ) {


Leave a Reply

Your email address will not be published. Required fields are marked *