Support

Account

Home Forums Add-ons Repeater Field Custom Post Type Generation Using ACF Repeater Fields ONLY Reply To: Custom Post Type Generation Using ACF Repeater Fields ONLY

  • This has now been solved:

    if( have_rows('custom_post_types', 'option') ):
                while( have_rows('custom_post_types', 'option') ) : the_row();
            
                // ACF Custom Label Declarations
            
                $cpt_name_plural = esc_html__( '"' . get_sub_field('cpt_name_plural') . '"' );
                $cpt_name_single = esc_html__( '"' . get_sub_field('cpt_name_single') . '"' );
                $cpt_label_add_new = esc_html__( '"' . get_sub_field('cpt_label_add_new') . '"' );
                $cpt_label_add_new_item = esc_html__( '"' . get_sub_field('cpt_label_add_new_item') . '"' );
                $cpt_label_edit_item = esc_html__( '"' . get_sub_field('cpt_label_edit_item') . '"' );
                $cpt_label_new_item = esc_html__( '"' . get_sub_field('cpt_label_new_item') . '"' );
                $cpt_label_view_item = esc_html__( '"' . get_sub_field('cpt_label_view_item') . '"' );
                $cpt_label_search_items = esc_html__( '"' . get_sub_field('cpt_label_search_items') . '"' );
                $cpt_label_not_found = esc_html__( '"' . get_sub_field('cpt_label_not_found') . '"' );
                $cpt_label_not_found_in_trash = esc_html__( '"' . get_sub_field('cpt_label_not_found_in_trash') . '"' );
                $cpt_label_parent_item_colon = esc_html__( '"' . get_sub_field('cpt_label_parent_item_colon') . '"' );
                $cpt_label_all_items = esc_html__( '"' . get_sub_field('cpt_label_all_items') . '"' );
                $cpt_label_archives = esc_html__( '"' . 
            get_sub_field('cpt_label_archives') . '"' );
                $cpt_label_attributes = esc_html__( '"' . get_sub_field('cpt_label_attributes') . '"' );
                $cpt_label_insert_into_item = esc_html__( '"' . get_sub_field('cpt_label_insert_into_item') . '"' );
                $cpt_label_uploaded_to_this_item = esc_html__( '"' . get_sub_field('cpt_label_uploaded_to_this_item') . '"' );
                $cpt_label_featured_image = esc_html__( '"' . get_sub_field('cpt_label_featured_image') . '"' );
                $cpt_label_set_featured_image = esc_html__( '"' . get_sub_field('cpt_label_set_featured_image') . '"' );
                $cpt_label_remove_featured_image = esc_html__( '"' . get_sub_field('cpt_label_remove_featured_image') . '"' );
                $cpt_label_use_featured_image = esc_html__( '"' . get_sub_field('cpt_label_use_featured_image') . '"' );
                $cpt_label_menu_name = esc_html__( '"' . get_sub_field('cpt_label_menu_name') . '"' );
                $cpt_label_filter_items_list = esc_html__( '"' . get_sub_field('cpt_label_filter_items_list') . '"' );
                $cpt_label_items_list_navigation = esc_html__( '"' . get_sub_field('cpt_label_items_list_navigation') . '"' );
                $cpt_label_items_list = esc_html__( '"' . get_sub_field('cpt_label_items_list') . '"' );
                $cpt_label_name_admin_bar = esc_html__( '"' . get_sub_field('cpt_label_name_admin_bar') . '"' );
            
                // Register Custom Post Type
                $cpt_name = get_sub_field('cpt_name');
                $cpt_args = array(
                    'label' => $cpt_name,
                    'description' => '',
                    'public' => true,
                    'publicly_queryable' => true,
                    'show_ui' => true,
                    'show_in_rest' => false,
                    'rest_base' => '',
                    'has_archive' => true,
                    'show_in_menu' => true,
                    'exclude_from_search' => false,
                    'capability_type' => 'post',
                    'map_meta_cap' => true,
                    'hierarchical' => false,
                    'rewrite' => array( 'slug' => $cpt_name, 'with_front' => true ),
                    'query_var' => true,
                    'menu_position' => 5,
                    'menu_icon' => 'dashicons-admin-post',
                    'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ),
                    'taxonomies' => array( 'category', 'post_tag' ),
                    'labels' => array(
                        'name' => $cpt_name_plural,
                        'singular_name' => $cpt_name_single,
                        'menu_name' => $cpt_label_menu_name,
                        'add_new' => $cpt_label_add_new,
                        'add_new_item' => $cpt_label_add_new_item,
                        'edit_item' => $cpt_label_edit_item,
                        'new_item' => $cpt_label_new_item,
                        'view_item' => $cpt_label_view_item,
                        'search_items' => $cpt_label_search_items,
                        'not_found' => $cpt_label_not_found,
                        'not_found_in_trash' => $cpt_label_not_found_in_trash,
                        'parent_item_colon' => $cpt_label_parent_item_colon,
                        'all_items' => $cpt_label_all_items,
                        'archives' => $cpt_label_archives,
                        'attributes' => $cpt_label_attributes,
                        'insert_into_item' => $cpt_label_insert_into_item,
                        'uploaded_to_this_item' => $cpt_label_uploaded_to_this_item,
                        'featured_image' => $cpt_label_featured_image,
                        'set_featured_image' => $cpt_label_set_featured_image,
                        'remove_featured_image' => $cpt_label_remove_featured_image,
                        'use_featured_image' => $cpt_label_use_featured_image,
                        'filter_items_list' => $cpt_label_filter_items_list,
                        'items_list_navigation' => $cpt_label_items_list_navigation,
                        'items_list' => $cpt_label_items_list,
                        'name_admin_bar' => $cpt_label_name_admin_bar
                    )
                );
                register_post_type( $cpt_name, $cpt_args );
            
                endwhile;
            endif;