Skip to content

Instantly share code, notes, and snippets.

@hssktm
Created August 7, 2025 20:43
Show Gist options
  • Select an option

  • Save hssktm/143acd83c78bbe85c36552dfb0adca6d to your computer and use it in GitHub Desktop.

Select an option

Save hssktm/143acd83c78bbe85c36552dfb0adca6d to your computer and use it in GitHub Desktop.
Content Flexible ACF
function flexible_content_repeater($posts, $query) {
$categories = array();
if ('custom-repeater' == $query->get('post_type')) {
if (have_rows('my_flexible_content')) {
while (have_rows('my_flexible_content')) {
the_row();
if (get_row_layout() == 'name_row_label_1') {
$name_field = get_sub_field('name_my_field');
$categories[] = (object) array(
'visible_module' => 'true',
'name_my_field' => $name_field,
);
}
}
}
}
if (!empty($categories)) {
return $categories;
}
return $posts;
}
add_filter('the_posts', 'flexible_content_repeater', 10, 2);
function custom_field($value) {
global $post;
return $post->$value;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment