Home › Forums › Bug Reports › [5.0.x] Most pages don't show up when adding a rule to target a specific page › Reply To: [5.0.x] Most pages don't show up when adding a rule to target a specific page
Okay, figured it out.
The error is in acf_get_posts() and the $offset variable:
$offset = 0;
// ...
// loop over posts and find $i
foreach( $all_posts as $offset => $p ) {
if( $p->ID == $match_id ) {
break;
}
}
// order posts
$all_posts = get_page_children( 0, $all_posts );
for( $i = $offset; $i < ($offset + $length); $i++ ) {
$offset is used in the foreach loop, which then breaks it when trying to do the for loop at the end. Changing $offset => $p
to $postOffset => $p
, or even just => $p
, solves the issue.
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.