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
Thank for your reply @elliot I will try this solution. I work on another solution but I do not know yet if it’s the most efficient.
My solution is as follows:
I create a “next_page” field. Whenever WordPress meets a flexible field, I increment my content in a variable $myContent.
When WordPress meets a field next_page I do this:
$myContent = "<--nextpage -->\n"
at the end of my loop I attribute $myCONTENT to the_content() and I appear like this:
global $ post;
$post-> post_content = $MyContent;
setup_postdata($post);
remove_filter('the_content', 'wpautop');
the_content();
wp_link_pages();
This works well but I do not know what it is worth in terms of performance.
Your solution looks more flexible. I would try in the coming days.
thank you very much
Hi @elliot ,
Thanks for your reply. In fact I think I expressed myself badly. I have a flexible field with subfields that manage my posts’ content. Is this possible with any means (adding a specific field or putting eg <!– nextpage –> in WISIWIG field) to separate the flexible field into multiple page?
Unfortunately, I have not found a plugin able to do this would. If I have the time and skills I would try to create a field. Thanks you for your reply.
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.