Created
August 7, 2025 20:43
-
-
Save hssktm/143acd83c78bbe85c36552dfb0adca6d to your computer and use it in GitHub Desktop.
Content Flexible ACF
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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