ACF Archive is not working, Advanced Custom Fields is not installed.

get_custom_post_types(); foreach ( $post_types as $key => $post_type ) { $this->add_menu( $key ); } } /** * @todo hack to solve the order menu issue (init hook) * * @param $menu_order * @return mixed */ function menu_order( $menu_order ) { global $submenu; foreach ( $submenu as $key => $data ) { if ( strpos( $key, '-archive-options' ) !== false ) { $submenu[$key] = array_reverse( $submenu[$key], true ); } } return $menu_order; } /** * Load the ACF Assets only on archive options page */ function admin_enqueue_scripts() { $screen = get_current_screen(); foreach ( $this->admin_pages as $cpt => $admin_page ) { if ( $this->get_admin_page_slug( $cpt ) == $screen->id ) { acf_enqueue_scripts(); } } } /** * Load ACF spinner on page submit */ function admin_footer() { $screen = get_current_screen(); foreach ( $this->admin_pages as $cpt => $admin_page ) { if ( $this->get_admin_page_slug( $cpt ) == $screen->id ) { $this->print_spinner_script(); } } } private function get_admin_page_slug( $cpt ) { return "admin_page_{$cpt}-archive-options"; } /** * Print ACF spinner script */ private function print_spinner_script() { ?> 'edit.php?post_type=' . $cpt, 'page_title' => $page_name, 'menu_title' => $page_name, 'capability' => 'edit_posts', 'menu_slug' => $cpt . '-archive-options', ); add_submenu_page( $options['parent_slug'], $options['page_title'], $options['menu_title'], $options['capability'], $options['menu_slug'], [ $this, 'render_menu' ] ); $this->admin_pages[$cpt] = $page_name; } /** * Render the archive options page */ public function render_menu() { $screen = get_current_screen(); $parts = explode( '-', $screen->parent_base ); $post_id = $parts[0]; if ( isset( $_POST[ $post_id ] ) ) { if( acf_verify_nonce( $post_id ) ) { if( acf_validate_save_post(true ) ) { acf_save_post( $post_id ); } } } $field_groups = acf_get_field_groups( array( 'post_id' => $post_id ) ); if ( empty( $field_groups ) ) { echo '

Not fields groups are attach to this page.

'; return; } $title = ucwords( str_replace( '-', ' ', $screen->parent_base ) ); ?>

$post_id, 'screen' => $post_id, 'nonce' => $post_id, )); foreach( $field_groups as $field_group ) { $fields = acf_get_fields($field_group); acf_render_fields( $post_id, $fields ); } ?>

admin_pages ) { foreach( $this->admin_pages as $cpt => $admin_page ) { $choices[ $cpt ] = $admin_page; } } return $choices; } /** * Check if we are in the current post type for showing the fields. * * @param $match * @param $rule * @param $options * @return bool */ function location_rules_match_archive( $match, $rule, $options ) { $screen = get_current_screen(); $parts = explode( '-', $screen->parent_base ); return $parts[0] == $rule['value']; } /** * Get all the custom post types with archive * * @return array */ private function get_custom_post_types() { $args = array( 'public' => true, 'has_archive' => true, '_builtin' => false ); return apply_filters( 'acf_archive_post_types', get_post_types( $args ) ); } } new ACF_Archive();