Home › Forums › Add-ons › Flexible Content Field › Pagination › Reply To: Pagination
I’ll try to explain but I’m not an expert in php. I do not know if I did it right but it works. I ended up using the elliot’s solution and it works well.
1. i create a field “break”;
2. Before the loop “while” i get the page create a counter variable which starts at 1 and gets increased each time the “break” layout is used like elliot says :
<?php $paged = (get_query_var('page')) ? get_query_var('page') : 1;
$MyContent = " " ;//variable for <!--nextpage-->
$count =1; ?>
3. Then the loop
<?php while(has_sub_field("content")): ?>
<?php if(get_row_layout() == "break"): ?>
<?php $MyContent .= "<!--nextpage-->\n";
$count++; ?>
<?php endif; ?>
<?php if(get_row_layout() == "section_content"): ?>
<?php if ($count != $paged){
continue; //ignore the current loop’s layout.
}?>
//your content
<?php endif; ?>
<?php endwhile; ?>
///after the loop put pagination
<?php global $post;
$post->post_content = $MyContent;
setup_postdata($post);
wp_link_pages();
?>
Sorry for my english, i hope that help you
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.