Opened 5 months ago
Last modified 3 months ago
#22867 closed defect (bug)
Function wp_get_nav_menu_items - Fatal error - Wordpress 3.5 and earlier — at Version 1
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Menus | Version: | 3.3 |
| Severity: | normal | Keywords: | reporter-feedback |
| Cc: |
Description (last modified by SergeyBiryukov)
The function wp_get_nav_menu_items fails when a "Page" type post has been added to a menu.
This is a fresh install of Wordpress 3.5, using the "Sample Page" page added to a menu called "main_menu". This menu has no other menu options added to it. This bug also occurs in earlier versions of Wordpress.
Sample PHP Code:
<?php $menu_name = 'main_menu'; $nav_menu_object = wp_get_nav_menu_object($menu_name); $menu_id = $nav_menu_object->term_id; $menu_items = wp_get_nav_menu_items($menu_id); <<--- Error occurs here ?>
The following error occurs:
Fatal error: Call to a member function get_page_permastruct() on a non-object in C:\xampp\htdocs\lchs4\wp-includes\link-template.php on line 271
This occurs in the following area of code:
function _get_page_link( $post = false, $leavename = false, $sample = false ) {
global $wp_rewrite;
$post = get_post( $post );
$draft_or_pending = in_array( $post->post_status, array( 'draft', 'pending', 'auto-draft' ) );
$link = $wp_rewrite->get_page_permastruct(); <--- happens here
Essentially, the variable $wp_rewrite shows as <Uninitialized> when viewed in xdebug using Eclipse.
Change History (1)
comment:1
SergeyBiryukov — 5 months ago
- Component changed from General to Menus
- Description modified (diff)
Note: See
TracTickets for help on using
tickets.
