Make WordPress Core

Opened 13 years ago

Last modified 16 months ago

#18282 reopened defect (bug)

Issue with admin page hierarchy in Menu admin

Reported by: hcceast's profile hcceast Owned by:
Milestone: Awaiting Review Priority: normal
Severity: critical Version: 3.2.1
Component: Menus Keywords: needs-patch needs-screenshots changes-requested
Focuses: Cc:

Description

Under Appearance > Menus in the left column under Pages, if I have more than 50 pages, the hierarchy view gets messed up. The issue seems to be related to paginate.

If I change the "50" on lines 589 and 809 of wp-admin/includes/nav_menu.php to "955" the hierarchal admin menu works with 50+ pages.

Attached are two XML files. One contains 50 pages and the other contains 53 pages. I've loaded them into fresh installs of 3.2.1 using the twenty eleven theme and no plugins.

Paginate is great if it works right, if it won't work, just increase the number per page to something very high and people can scroll. I'd rather scroll than not have hierarchy work right.

Link to 50 page XML -- http://cloud.hcc.me/0g3X3O310s3l3i2N363n

Link to 53 page XML -- http://cloud.hcc.me/302e0c391A14193m2V2e

Pastebin of wp-admin/includes/nav_menu.php -- http://pastebin.com/0FRAmMkS

Attachments (4)

page xml .zip (7.1 KB) - added by hcceast 13 years ago.
XML Page Files
Screen shot 2011-07-28 at 10.03.43 AM.png (30.6 KB) - added by hcceast 13 years ago.
Screen shot of admin menu (all subs should be under parents)
18282-disable-nav-menu-pagination.patch (621 bytes) - added by Aries-Belgium 12 years ago.
Patch to work around nav menu pagination
preserve-page-and-taxonomy-hierarchy.php (1.9 KB) - added by SergeyBiryukov 11 years ago.

Download all attachments as: .zip

Change History (84)

@hcceast
13 years ago

XML Page Files

@hcceast
13 years ago

Screen shot of admin menu (all subs should be under parents)

#2 @SergeyBiryukov
13 years ago

Taxonomies are also affected.

Closed #19837 and #20351 as duplicates.

#3 @Marventus
13 years ago

  • Cc frandeazevedo@… added

#4 @Marventus
13 years ago

I suspect the $depth parameter could be failing during pagination.
I'll take a look into it see if I can find anything.

Last edited 13 years ago by Marventus (previous) (diff)

#5 @Whissi
13 years ago

  • Cc Whissi added
  • Version changed from 3.2.1 to 3.3.2

Is anybody working on this? The current release (3.3.2) is still affected.

#6 @JustinSainton
13 years ago

  • Version changed from 3.3.2 to 3.2.1

The version tag is used for when the issue was introduced, not the most recent version it occurs in.

#7 @dmaras
12 years ago

  • Version changed from 3.2.1 to 3.4

hello,

i cant find this line in version 3.4 and i have same issue...

Edit:
I have it i was looking in wp-includes/nav-menu.php

Last edited 12 years ago by dmaras (previous) (diff)

#8 @SergeyBiryukov
12 years ago

  • Version changed from 3.4 to 3.2.1

Version number indicates when the bug was initially introduced/reported.

#9 @SergeyBiryukov
12 years ago

#23286 was marked as a duplicate.

#10 @SergeyBiryukov
12 years ago

  • Owner Andrew Smith deleted
  • Status changed from new to reviewing

#11 @energy0m
12 years ago

  • Cc marc@… added
  • Severity changed from major to blocker

When is this ticket going to be resolved? is there a patch? This is core functionality keeping my project from launching which is over 18months old. not cool. I can put in pages manually but my client cant manage them and as it turns out they have a very deep sitemap to place in the menu's section.

so again.. when is this to be resolved?

#12 @Marventus
12 years ago

  • Severity changed from blocker to major

@energy0m: the issue will be resolved when... someone takes the time to resolve it. It seems Sergey is looking into it, but if you are in a rush, I suggest you contact him and - here's a crazy idea! - offer him to help. In the meantime, I can only suggest you take a chill pill and read up on what Open Source is all about: http://en.wikipedia.org/wiki/Open_source.

#13 @energy0m
12 years ago

How can I help him when I don't know enough about PHP to resolve the problem?

#14 @SergeyBiryukov
12 years ago

I'm not actually looking into it yet, I've just removed the previous owner so that someone else could take over this ticket. Feel free to submit a patch.

#15 @helen
12 years ago

This is essentially a visual bug - the hierarchy is not actually altered, and since nav menus specifically do not rely on the page hierarchy, nothing is broken beyond the visual. Yes, it is a bug and yes, it is frustrating, but it shouldn't be something that holds up a launch.

#16 @SergeyBiryukov
12 years ago

#24436 was marked as a duplicate.

#17 @allergicvegetarian
12 years ago

This issue also effects categories as well, when you are creating a menu. I'm making a navigation menu that isn't on a specific page.

Obviously, this isn't going to get fixed soon, given a computer programmers time for open source projects is directly related to the amount of extra work their real job requires them to program "for free" under the heading of "salaried" (work 60 hours, get paid for 40). LOL I fully support the Computer Programmer in this, and in no way, am I dissing the programmer. I'm also against such abuse of programmers.

Last edited 12 years ago by allergicvegetarian (previous) (diff)

@Aries-Belgium
12 years ago

Patch to work around nav menu pagination

#18 @Aries-Belgium
12 years ago

The issue is indeed the pagination that breaks the hierarchy of the pages. It's possible that some child pages aren't on the same page/section than the parent page which confuses the Walker.

In the attachment a patch for a quick workaround by disabling the pagination for the "All"-tab. When I find the time I will see if I can come up with a solution where the pagination doesn't break the hierarchy but for now this patch also works.

#19 @Aries-Belgium
12 years ago

  • Cc Aries-Belgium added

#20 @moraleida.me
11 years ago

  • Cc moraleida.me added

#21 @SergeyBiryukov
11 years ago

#25262 was marked as a duplicate.

#22 @alettieri
11 years ago

  • Cc alettieri added

#23 @SergeyBiryukov
11 years ago

#27143 was marked as a duplicate.

#24 follow-up: @davidfhannes
11 years ago

I tried the patch to no avail:

	$posts = $get_posts->query( array_merge( $args, array( 'nopaging' => true ) ) ); 

I really need assistance on this issue. This is my issue at hand:

Screen shot: http://162.144.54.1/wp-content/uploads/ss_reply_to_Jody_2-16-14.jpg

Last edited 11 years ago by SergeyBiryukov (previous) (diff)

#25 in reply to: ↑ 24 ; follow-ups: @SergeyBiryukov
11 years ago

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

#26 @SergeyBiryukov
11 years ago

#28031 was marked as a duplicate.

#27 @apsolut
10 years ago

I like @SergeyBiryukov fix! thumbs up!

#28 @SergeyBiryukov
10 years ago

#29252 was marked as a duplicate.

#29 @SergeyBiryukov
10 years ago

#30122 was marked as a duplicate.

#30 @energy0m
10 years ago

@SergeyBiryukov ... you rock!

#31 @SergeyBiryukov
10 years ago

#30992 was marked as a duplicate.

#32 @chunkysteveo
10 years ago

Great little patch plugin @SergeyBiryukov, solved my head bashing!

#33 @m7csat
10 years ago

Just wanted to add my thanks! Solved my frustrations.

#34 @p10design
9 years ago

Is there a reason why this was never fixed?
Why is there a plugin to fix a core functionality?
What are the steps one should take to get this issue to be fixed?

Thanks!

#35 @majemedia
9 years ago

For larger sites that have a massive number of pages this is causing issues. The steps in the original description properly duplicate this.

The plugin by @SergeyBiryukov works as designed, but when you're dealing with a large number of pages (> 500) the nav menu page takes a long time.

The patch by @Aries-Belgium run into the same load time issues.

#36 @sjlevy
9 years ago

I can confirm that this is still an issue with 4.5.2

@SergeyBiryukov 's plugin works by eliminating pagination under 'View All'

#37 @xavierserranoa
8 years ago

i have been looking into this. the only solution i could present for this scenerio is to have the walker or the query results $post variable be handled the same way it is handled by class-wp-posts-list-table look at _display_rows_hierarchical and _page_rows. this way the displaying of the posts will work with pagination. still kind of testing it out and seeing what could be done would love help or pointers if anyone has any.

#38 @SergeyBiryukov
8 years ago

#40880 was marked as a duplicate.

#39 @SergeyBiryukov
7 years ago

#40827 was marked as a duplicate.

#40 @raykaii
7 years ago

Hi,
Is there a reason why this was never fixed?

This bug is also affecting Woocommerce in a Bad way.

As you can see at the ticket https://core.trac.wordpress.org/ticket/40827 and the ticket at Woocommerce at https://github.com/woocommerce/woocommerce/issues/13040 Woocommerce devs did comment saying this bug is affecting Woocommerce too.

Would be nice to have a real fix and a fix that would work with Woocommerce.

Last edited 7 years ago by raykaii (previous) (diff)

#41 follow-up: @torndownunits
7 years ago

I can't believe this is still an issue, but thank you @SergeyBiryukov for the fix. as @raykaii said, it's a complete pain with WooCommerce.

#42 in reply to: ↑ 41 @raykaii
7 years ago

Replying to torndownunits:

I can't believe this is still an issue, but thank you @SergeyBiryukov for the fix. as @raykaii said, it's a complete pain with WooCommerce.

hey if you could complain about at WooCommerce it mite help WC devs could fix it if ppl complain about it. Do it here: https://github.com/woocommerce/woocommerce/issues/13040

#43 follow-up: @raykaii
7 years ago

@torndownunits did the temp fix work for WC ? it's not working for me.

Last edited 7 years ago by raykaii (previous) (diff)

#44 in reply to: ↑ 43 ; follow-up: @torndownunits
7 years ago

Replying to raykaii:

@torndownunits did the temp fix work for WC ? it's not working for me.

Yes, I used the plugin from post #25. It's not ideal but it makes the Product Categories hierarchy at least display correctly in Appearance--> Menus (using View All) which is what I needed. It was a mess before, and now the hierarchy of everything is at least correct. Using the editor with dozens (never mind hundreds) of items is a pain still, but I can use it. Also, I ended up here from your posts at Woo. But isn't this a problem with all items in the Menu editor, not just Woo items? The editor basically is just horrible when dealing with dozens (never mind hundreds) of options in general.

#45 @SergeyBiryukov
7 years ago

#41440 was marked as a duplicate.

#46 in reply to: ↑ 44 ; follow-up: @raykaii
7 years ago

  • Keywords needs-screenshots added

Replying to torndownunits:

Replying to raykaii:

@torndownunits did the temp fix work for WC ? it's not working for me.

Yes, I used the plugin from post #25. It's not ideal but it makes the Product Categories hierarchy at least display correctly in Appearance--> Menus (using View All) which is what I needed. It was a mess before, and now the hierarchy of everything is at least correct. Using the editor with dozens (never mind hundreds) of items is a pain still, but I can use it. Also, I ended up here from your posts at Woo. But isn't this a problem with all items in the Menu editor, not just Woo items? The editor basically is just horrible when dealing with dozens (never mind hundreds) of options in general.

woocommerce (mikejolley) said they could fix it but i was the only one complaining about it. they need more ppl reporting it so they take the time to fix it. plz, ask them to fix this bug or it never going to be fixed :(.

#47 in reply to: ↑ 25 ; follow-up: @raykaii
7 years ago

Replying to SergeyBiryukov:

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

So where do we add this file to?

#48 in reply to: ↑ 47 @torndownunits
7 years ago

Replying to raykaii:

Replying to SergeyBiryukov:

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

So where do we add this file to?

Make a folder inside your plugins folder. Put the file in it. Go into your dashboard, go to plugins, activate it. You will see it listed in your plugins.

#49 in reply to: ↑ 46 @torndownunits
7 years ago

Replying to raykaii:

Replying to torndownunits:

Replying to raykaii:

@torndownunits did the temp fix work for WC ? it's not working for me.

Yes, I used the plugin from post #25. It's not ideal but it makes the Product Categories hierarchy at least display correctly in Appearance--> Menus (using View All) which is what I needed. It was a mess before, and now the hierarchy of everything is at least correct. Using the editor with dozens (never mind hundreds) of items is a pain still, but I can use it. Also, I ended up here from your posts at Woo. But isn't this a problem with all items in the Menu editor, not just Woo items? The editor basically is just horrible when dealing with dozens (never mind hundreds) of options in general.

woocommerce (mikejolley) said they could fix it but i was the only one complaining about it. they need more ppl reporting it so they take the time to fix it. plz, ask them to fix this bug or it never going to be fixed :(.

I didn't see them say they'd fix anything? They said it's a problem with Wordpress, which it is. It's not specifically a problem with Woo taxonomies, it's a problem with all taxonomies. It's not really their problem to fix.

#50 follow-up: @randNotAyn
7 years ago

"Make a folder inside your plugins folder. Put the file in it. Go into your dashboard, go to plugins, activate it. You will see it listed in your plugins."

AND.... DOWNLOAD the file above ... DO NOT copy/paste the code into a text file, saved it, uploaded it, and it didn't work.

HOWEVER ... when I Select All and add (Product Categories) it doesn't add them all ... 130 out of 241 menus.

Last edited 7 years ago by randNotAyn (previous) (diff)

#51 follow-up: @danburzo
7 years ago

I found a somewhat simpler (more targeted) solution to disable pagination in these meta boxes, by placing a filter on the nav_menu_meta_box_object hook:

<?php
  add_filter( 'nav_menu_meta_box_object', array( $this, 'disable_pagination_in_menu_meta_box' ) );

  function disable_pagination_in_menu_meta_box($obj) {
    $obj->_default_query = array(
      'posts_per_page' => -1
    );
    return $obj;
  }
?>

Please be advised that this uses the private-looking _default_query, so your mileage may vary, but it worked very well for me.

#52 follow-up: @danburzo
7 years ago

Update: Needs to be added with priority 9 to work well with the default filter _wp_nav_menu_meta_box_object. Corrected line below:

<?php
add_filter( 'nav_menu_meta_box_object', 'disable_pagination_in_menu_meta_box', 9 );

#53 in reply to: ↑ 52 @torndownunits
7 years ago

Replying to danburzo:

Update: Needs to be added with priority 9 to work well with the default filter _wp_nav_menu_meta_box_object. Corrected line below:

<?php
add_filter( 'nav_menu_meta_box_object', 'disable_pagination_in_menu_meta_box', 9 );

Thanks, I will try this out.

#54 in reply to: ↑ 50 ; follow-up: @torndownunits
7 years ago

Replying to randNotAyn:

"Make a folder inside your plugins folder. Put the file in it. Go into your dashboard, go to plugins, activate it. You will see it listed in your plugins."

AND.... DOWNLOAD the file above ... DO NOT copy/paste the code into a text file, saved it, uploaded it, and it didn't work.

HOWEVER ... when I Select All and add (Product Categories) it doesn't add them all ... 130 out of 241 menus.

I am not sure how many it's working with successfully on my site, but it's not as many as you are trying it with for sure. I am going to try out the solution just added by @danburzo as well. See if one works better than the other.

#55 in reply to: ↑ 54 @randNotAyn
7 years ago

Replying to torndownunits:

Thank you for helping!
If you'd like access to my site let me know and I can email credentials (it's at a temp site).

#56 @lnedo
7 years ago

I just wanted to add an update that I am also experiencing this issue and my site has nowhere near 500 pages. I have 71 total pages. This is a site for a school, so I have many pages added as children of a main "Schools" page. The fact that the parent starts with an 'S' causes the majority of the children to appear as top-level items when pagination is enabled (not in alpha order, either.)

Adding the filter @danburzo suggested worked perfectly.

Last edited 7 years ago by lnedo (previous) (diff)

#57 @damtii
7 years ago

Hi,
I am having similar issue on my site when using woocommerce.
I am having around 150 categories and I can't see the product category hierarchy right.

any fix for that?

thanks.

#58 @Baroninn
6 years ago

I had the same issue,
Tried all kinds of solutions.
The one that worked for me was to download this plugin and activate
https://core.trac.wordpress.org/attachment/ticket/18282/preserve-page-and-taxonomy-hierarchy.php

You can see the download button at the bottom of the page.
You then need to create a folder in your plugins folder and place this file in there.
Everything was perfect for me after that.

#59 @helpadrian
6 years ago

Hello

i am using the plugin > preserve page and taxonomy hierarchy. It works well (thanks), but all of a sudden it is not giving me all the product categories i have created (not listing all of them in the add to menu section under view all).. there is alot, over 900 product categories and counting... Please help as i cant seem to find a work around. It will be impossible for me(ie take to long so i wont do it) to add those many items to the menu in their respective sub categories.

I have also tried @danburzo advice but unfortunately it did not work for me.

Please help

Last edited 6 years ago by helpadrian (previous) (diff)

#60 @flyingkites
6 years ago

While this issue relates to WordPress, my interest is with WooCommerce.

For WooCommerce users who have a large number of Product Categories, the patch provided by @SergeyBiryukov will stop working after a certain number.

The patch essentially removes pagination. However once you get "too many" categories you may end up with a blank nav-pages.php page without any error showing in site error logs. Your only option is to then remove the patch. (If I eventually find server settings that will allow it to run I will repost but our test show it fails around 2500 categories).

It is naive of @helen to say that this fundamental defect in WordPress should not stop a site going live. Being able to create specific menus for ecommerce is a must in order to provide customers with a unique customer experience. If you have over 2000 categories, many with duplicate names as happens on many eCommerce sites, you cannot distinguish category names if the category list does not show the hierarchy. Being able to see the hierarchy in a paginated view is a must.

It would be good if the WP team took the issue seriously.

#61 @SergeyBiryukov
5 years ago

#47639 was marked as a duplicate.

#62 @hmobron
5 years ago

@flyingkites can be.

But after all this year a experience the same problem and the fix helped.

Very strange it still exists.

#63 @olcoil
5 years ago

Sad this is still an issue. Big stores need big menus and this creates big problems for us!

#64 in reply to: ↑ 51 @johnmadox
4 years ago

Hello,
I am kinda new to wordpress and am building an online store by the help of different videos.
Can you please explain where and how to add this code?
I would really appreciate if anyone could help me out.
Thanks

Replying to danburzo:

I found a somewhat simpler (more targeted) solution to disable pagination in these meta boxes, by placing a filter on the nav_menu_meta_box_object hook:

<?php
  add_filter( 'nav_menu_meta_box_object', array( $this, 'disable_pagination_in_menu_meta_box' ) );

  function disable_pagination_in_menu_meta_box($obj) {
    $obj->_default_query = array(
      'posts_per_page' => -1
    );
    return $obj;
  }
?>

Please be advised that this uses the private-looking _default_query, so your mileage may vary, but it worked very well for me.

#65 @SergeyBiryukov
4 years ago

#51169 was marked as a duplicate.

#66 @lawix
4 years ago

Thanks @Baroninn this temporarily fix my issue

why nothing is done to fix problem in the core? :/

#67 in reply to: ↑ 25 @fmarconi
4 years ago

Replying to SergeyBiryukov:

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

Thanks! That worked for me

#68 in reply to: ↑ 25 @corvusmile
4 years ago

  • Resolution set to worksforme
  • Status changed from reviewing to closed

It works like a lifesaver. Thanks for that. You'd make it as a plugin and submit it in the repo. It took almost 2 days for me to find the solution. A plugin will help all who have less technical concepts.

Replying to SergeyBiryukov:

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

Last edited 4 years ago by corvusmile (previous) (diff)

This ticket was mentioned in Slack in #core by danburzo. View the logs.


4 years ago

#70 @Clorith
4 years ago

  • Resolution worksforme deleted
  • Status changed from closed to reopened

Re-opening ticket, as it was unintentionally closed before a resolution was reached.

#71 @peterh4
4 years ago

Great thanks to @SergeyBiryukov for the patch preserve-page-and-taxonomy-hierarchy.php

It works well and keeps the hierarchy of all my 83 woocommerce product categories when trying to add them to a menu.

Unfortunately in the Appearance--> Menus (using View All) there are all the product categories being re-sorted alphabeticaly! Is it possible to keep the original sorting order of the product categories as well, together with keeping the hierarchy?

Thanks!

#72 follow-up: @SergeyBiryukov
4 years ago

#52580 was marked as a duplicate.

#73 @hmobron
2 years ago

After hour off searching, found this very old bug report.

11 years later, still a issue and fixed by the custom plugin. Very strange.

#74 follow-up: @DownHouse00
2 years ago

A very difficult bug. In 2023, the developers are still trying to fix it.

#75 @fatima656
23 months ago

  • Keywords changes-requested added

The request for it is open in 2017. It still exist in 2023 I spend my whole day still couldn't solve it. It's very sad to know that there is now fix for it.

Last edited 23 months ago by fatima656 (previous) (diff)

#76 in reply to: ↑ 74 ; follow-up: @fatima656
23 months ago

Replying to DownHouse00:

A very difficult bug. In 2023, the developers are still trying to fix it.

Did you get any solution?

#77 in reply to: ↑ 72 @fatima656
23 months ago

  • Severity changed from major to critical

Replying to SergeyBiryukov:

#52580 was marked as a duplicate.


Please test your patch with latest version of wordpress. It's not working for me.

#78 in reply to: ↑ 76 @DownHouse00
23 months ago

Replying to fatima656:

Replying to DownHouse00:

A very difficult bug. In 2023, the developers are still trying to fix it.

Did you get any solution?

Yes. This plugin work for me with last version of wp
https://github.com/IftekharSami/Preserve-Page-and-Taxonomy-Hierarchy-on-Edit-Menus-Screen-Version-0.1-Plugin-/blob/main/code

#79 in reply to: ↑ 25 @viablethought
22 months ago

Replying to SergeyBiryukov:

Replying to davidfhannes:

I tried the patch to no avail:

That patch is for pages (and other hierarchial post types), not for taxonomies.

I've created a workaround plugin to preserve hierarchy for both post types and taxonomies:
preserve-page-and-taxonomy-hierarchy.php.

Note that it only affects "View All" tab, not "Most Recent" or "Most Used".

This plugin/patch still works as of WordPress 6.1. However, how is this issue still a thing in 2023? This is just bad UX and causes confusion when building menus. Been chasing this down for a week before finally stumbling on this and luckily the plugin works to where I can feel confident with handing over a project to a client.

#80 @SergeyBiryukov
16 months ago

#59081 was marked as a duplicate.

Note: See TracTickets for help on using tickets.