ACF Archive is not working, Advanced Custom Fields is not installed.', 'acf-archive' ); ?>

get_custom_post_types(); foreach ( $post_types as $post_type => $post_type_object ) { $menu = 'edit.php?post_type=' . $post_type; if ( 'post' === $post_type ) { $menu = 'edit.php'; } $this->add_menu( $post_type_object->label, $menu ); } } /** * Load the ACF Assets only on archive options page * @param string $hook_suffix * @return void */ public function admin_enqueue_scripts( $hook_suffix ) { $screen = get_current_screen(); if ( $this->get_admin_page_slug( $screen->post_type ) === $hook_suffix ) { acf_enqueue_scripts(); } } /** * Load ACF spinner on page submit * @return void */ public function admin_footer() { $screen = get_current_screen(); if ( $this->get_admin_page_slug( $screen->post_type ) === $screen->id ) { $this->print_spinner_script(); } } /** * @param string $post_type * @return string */ private function get_admin_page_slug( $post_type ) { return $post_type . '_page_archive-options'; } /** * Print ACF spinner script * @return void */ private function print_spinner_script() { ?> $menu, 'page_title' => $page_name, 'menu_title' => $page_name, 'capability' => 'edit_posts', 'menu_slug' => 'archive-options', ]; add_submenu_page( $options['parent_slug'], $options['page_title'], $options['menu_title'], $options['capability'], $options['menu_slug'], [ $this, 'render_menu' ] ); } /** * Render the archive options page */ public function render_menu() { $screen = get_current_screen(); $post_type = $screen->post_type; if ( isset( $_POST[ $post_type ] ) && acf_verify_nonce( $post_type ) && acf_validate_save_post(true ) ) { acf_save_post( $post_type ); } $field_groups = acf_get_field_groups( [ 'post_id' => $post_type ]); if ( empty( $field_groups ) ) { echo '

' . __( 'No field groups are associated to this archive.', 'acf-archive' ) . '

'; return; } $post_type_object = get_post_type_object( $post_type ); ?>

label ); ?>

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

get_custom_post_types() as $post_type => $post_type_object ) { $choices[ $post_type ] = sprintf( __( '%s Archive', 'acf-archive' ), $post_type_object->label ); } return $choices; } /** * Check if we are in the current post type for showing the fields. * * @param $match * @param $rule * @param $options * @return bool */ public function location_rules_match_archive( $match, $rule, $options ) { if ( ! isset( $_GET['post_type'] ) || ! isset( $_GET['page'] ) ) { return $match; } return $_GET['post_type'] == $rule['value'] && $_GET['page'] == 'archive-options'; } /** * Get all the custom post types with archive * * @return array */ private function get_custom_post_types() { static $post_types; if ( null !== $post_types ) { return $post_types; } $args = [ 'public' => true, 'has_archive' => true, ]; $post_types = get_post_types( $args, 'objects' ); return $post_types = apply_filters( 'acf_archive_post_types', $post_types ); } } ACF_Archive::instance();