Support

Account

Forum Replies Created

  • Looks like I was just getting the page count in the wrong place. Here’s a working solution.

    <?php $pagecount = 0;
    
    while( has_sub_field("content") ) : 
      
      if(get_row_layout() == "page_break") :
      
        if(get_sub_field('break_here')){
          $pagecount++;	
        }
        
      endif;
    endwhile;
    ?>

    Then I can just use $pagecount elsewhere:

    <?php echo $pagecount; ?>

  • Hi @FourStacks, this isn’t quite it. This echoes and then increments each one.

    So if there are five, the result is this:

    12345

    but what I’m looking for just 5.

    Does that make sense?

  • Here’s one other solution I tried, but it did not work, it just spits out <p><!--nextpage--></p>:

    <?php while(has_sub_field("content")): ?>
      <?php if(get_row_layout() == "section_content"):  ?>
        <h2><?php the_sub_field("section_title"); ?></h2>
        
        <?php 
          $section_text = the_sub_field("section_text");
          $section_content = $section_text . '<!--nextpage-->';
          $content = apply_filters('acf_the_content', $section_content);
          echo $content;
        ?>
    
      <?php endif; ?>
    <?php endwhile; ?>
  • I think I’m trying to accomplish the exact same thing as @pixaro, but I’ve been spinning my wheels for hours and getting nowhere.

    To be clear, I’m trying to split each flexible content section into its own page, as if I were using <!--nextpage--> in the content.

    Here’s a screenshot of my relevant layouts. You can see I’m attempting to use a layout called “Page Break” containing a true/false field called “Break Here” to create the breaks.

    Here’s the simple, working loop I’m using to get the “Section Title” and “Section Text” into the page.

    <?php while(has_sub_field("content")): ?>
      <?php if(get_row_layout() == "section_content"):  ?>
        <h2><?php the_sub_field("section_title"); ?></h2>
        <?php the_sub_field("section_text"); ?>
      <?php endif; ?>
    <?php endwhile; ?>

    Beyond this, I’m lost. I’ve tried a number of things, including creating a counter using this information, but I could never get it to work.

    Could anyone possibly share a more complete solution?

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