Title: WP_Navigation_Fallback::create_classic_menu_fallback
Published: August 8, 2023
Last modified: February 24, 2026

---

# WP_Navigation_Fallback::create_classic_menu_fallback(): int|󠀁[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)󠁿

## In this article

 * [Return](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#wp--skip-link--target)

This function’s access is marked private. This means it is not intended for use 
by plugin or theme developers, only by core. It is listed here for completeness.

Creates a Navigation Menu post from a Classic Menu.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#return)󠁿

 int|[WP_Error](https://developer.wordpress.org/reference/classes/wp_error/) The
post ID of the default fallback menu or a [WP_Error](https://developer.wordpress.org/reference/classes/wp_error/)
object.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#source)󠁿

    ```php
    private static function create_classic_menu_fallback() {
    	// See if we have a classic menu.
    	$classic_nav_menu = static::get_fallback_classic_menu();

    	if ( ! $classic_nav_menu ) {
    		return new WP_Error( 'no_classic_menus', __( 'No Classic Menus found.' ) );
    	}

    	// If there is a classic menu then convert it to blocks.
    	$classic_nav_menu_blocks = WP_Classic_To_Block_Menu_Converter::convert( $classic_nav_menu );

    	if ( is_wp_error( $classic_nav_menu_blocks ) ) {
    		return $classic_nav_menu_blocks;
    	}

    	if ( empty( $classic_nav_menu_blocks ) ) {
    		return new WP_Error( 'cannot_convert_classic_menu', __( 'Unable to convert Classic Menu to blocks.' ) );
    	}

    	// Create a new navigation menu from the classic menu.
    	$classic_menu_fallback = wp_insert_post(
    		array(
    			'post_content' => $classic_nav_menu_blocks,
    			'post_title'   => $classic_nav_menu->name,
    			'post_name'    => $classic_nav_menu->slug,
    			'post_status'  => 'publish',
    			'post_type'    => 'wp_navigation',
    		),
    		true // So that we can check whether the result is an error.
    	);

    	return $classic_menu_fallback;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-navigation-fallback.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/class-wp-navigation-fallback.php#L139)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/class-wp-navigation-fallback.php#L139-L171)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Classic_To_Block_Menu_Converter::convert()](https://developer.wordpress.org/reference/classes/wp_classic_to_block_menu_converter/convert/)`wp-includes/class-wp-classic-to-block-menu-converter.php` |

Converts a Classic Menu to blocks.

  | 
| [wp_insert_post()](https://developer.wordpress.org/reference/functions/wp_insert_post/)`wp-includes/post.php` |

Inserts or update a post.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  | 
| [WP_Error::__construct()](https://developer.wordpress.org/reference/classes/wp_error/__construct/)`wp-includes/class-wp-error.php` |

Initializes the error.

  |

[Show 3 more](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_navigation_fallback/create_classic_menu_fallback/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_navigation_fallback%2Fcreate_classic_menu_fallback%2F)
before being able to contribute a note or feedback.