Home Forums ACF PRO Adding manual page breaks on repeater field


Adding manual page breaks on repeater field

  • Hi All

    I have been having a look around but can not seem to find anything about a solution to repeater fields and pagination.

    Currently I have a repeater field which is used to style a page into different “blocks”. You select the “type” of content and that then display is on the page An example:

    [main wp content]

    – full image block –

    -Normal writing section –


    -Normal writing section –

    This would then output content to build a page where you can use the repeater to change the layout etc.

    What i would like it to also add in a repeater option something like Page Break for breaking the page and adding in pagination.

    I am still learning PHP and to me I am not sure how i would even start.

  • Are you talking about creating multiple pages in the same say that WordPress will do if you add <!-- Nextpage --> into the content area?

  • Hi John

    Yeah that is the similar functionality I am looking for.

    At the moment <!– Next Page –> only works for the first content section and not any of ACF’s.

    That is why I would like to add a repeater type which you can insert where you want in the repeater loop to break up into another page.

  • This is basically functionality that you’ll need to custom build, but it is possible. I just did something similar where every row in a repeater field is a separate page on the front end.

    What I did was to create a loop that shows page links, similar to the page links that WP shows. I had to generate the page links /1, /2, /3, etc. Then in the page code I tested to see which of the repeater rows should be displayed and then looped through the repeater till it got to the right one and showed it.

    This isn’t something that ACF will do for you.

    Here is some code that might help you get it going. just some of what I used.

    // get the page number
    $page = 0;
    $base_url = $_SERVER['REQUEST_URI']
    if (preg_match('#/([0-9]+)/?$#', $_SERVER['REQUEST_URI'], $matches)) {
      $page = intval($matches[1]);
      $base_url = preg_replace('#[0-9]+/?$#', '', $base_url);
    // output page links
    $count = intval(get_post_meta($post->ID, 'repeater', true));
    if ($count) {
            for ($i=0; $i<$count; $i++) {
                <li><a href="<?php 
                  echo $base_url,$i,'/'; ?>><?php 
                  echo $i; ?></a></li>
    // output the right row
    $count = 0;
    if (have_rows($repeater)) {
      while (have_rows($repeater)) {
        if ($count == $page) {
          // output the content of this row
  • Thanks for this, it will help me get in the right direction!

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Adding manual page breaks on repeater field’ is closed to new replies.