WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Custom Menu Not Displaying on '404 Error' Page. (13 posts)

  1. mmattner
    Member
    Posted 3 years ago #

    As simple as the title, my custom menu is not displaying on the 404 error page, but it is displaying everywhere else as intended.

    I've done the following to register the menu:

    add_action( 'init', 'my_register_menu_function' );
    
    function my_register_menu_function() {
       register_nav_menu('primary', __('Primary Navigation'));
    }

    After which I call the menu in my theme by doing the following:

    $args = array(
        'theme_location'  => 'primary',
        'container'       => '',
        'container_class' => '',
        'container_id'    => '',
        'menu_class'      => '',
        'menu_id'         => '',
        'items_wrap'      => '%3$s');
    wp_nav_menu($args);
    
    $cats = array(
        'title_li'  => __( '<a href="#">Categories</a>' ),
        'taxonomy'  => 'category' );
    wp_list_categories( $cats );
    
    $gens = array(
        'title_li'  => __( '<a href="#">Custom Taxonomy</a>' ),
        'taxonomy'  => 'custom_tax' );
    wp_list_categories( $gens );

    That produces the menu as an unordered list. The menu has been setup in the appearance menu, and everything works as intended on index, archive, category, page, single, and custom taxonomy pages. But, for one reason or another, the custom menu is not displayed on the 404 page, only the menu items I've generated by calling wp_list_categories gets shown.

    Any clue why it wouldn't show up on this one page? Don't recall this being a problem before the upgrade to 3.2.1. Also, because the site is not yet 'live,' I cannot provide a link.

  2. ZinZangStudio
    Member
    Posted 3 years ago #

    Same problem here with no menu on 404 pages, and with additional absences on pages generated by MailPress plugin where subscribers manage their subscriptions.

    Poking around, I noticed something odd that likely gives a clue to the problem.

    Generate a 404 error by adding four numbers to the end of your URL, like "thedomain.com/7777". Does your menu now show up like it does in my case? Now try with three 7s, and see if the menu disappears again.

    My Permalink Settings are currently set to "Month and name". I'll keep troubleshooting and post back here.

    (using a severely modified theme that used to be Twenty Ten)
    edit: The problem here was happening before the upgrade to 3.21. Pretty sure it's been happening since 3.

  3. mmattner
    Member
    Posted 3 years ago #

    I can confirm that the menu shows up when adding four numbers to the end, as in your example "thedomain.com/7777" but not with anything less. I tried several other four number combinations and those seemed to have worked as well.

    I also tried a url that didn't exist, "thedomain.com/2011/07/sample-post/" and the menu did not show up in that case either.

    Odd that it worked with four numbers at the end.

    I have permalinks set the same as yours.

  4. ZinZangStudio
    Member
    Posted 3 years ago #

    Looking like a Permalinks issue.
    There is a "Permalinks problem - 4-digit IDs of posts" thread here since WP 2.86.

    Still hunting...

  5. ZinZangStudio
    Member
    Posted 3 years ago #

    Changing the Permalink structure to Custom:
    /%category%/%postname%-%post_id% or
    /%category%/%postname%/
    fixes my 404 page no custom menu problem, but not with my MailPress plugin pages.

  6. mmattner
    Member
    Posted 3 years ago #

    I changed my permalink structure to /%category%/%postname%/ and that fixed the issue.

    Thanks for pointing me in this direction, just wonder what it is about WordPress's handling of permalinks that affects the custom menu in this way.

  7. Nathan Shubert-Harbison
    Member
    Posted 2 years ago #

    Thanks for this solution. I was having the same problem and banging my head against the wall for a bit. Any idea why on earth this is happening? I wonder if there's a bug listed for it in Trac.

  8. ZinZangStudio
    Member
    Posted 2 years ago #

    I haven't yet given up learning what the exact cause is, it's just lost some priority. Are all 3 of us here seeing the problem on customized themes?

  9. Nathan Shubert-Harbison
    Member
    Posted 2 years ago #

    Yup, I had the exact same problem.

  10. ZinZangStudio
    Member
    Posted 2 years ago #

    Ok, glad to not be alone. :) Please post back if you find out anything, I'll do the same.

  11. Bozz
    Member
    Posted 2 years ago #

    I also have this problem on 404 pages with custom menus. The menu UL is there but has no content within it. Every other page loads fine. WordPress 3.3

  12. Bozz
    Member
    Posted 2 years ago #

    I have gone ahead and filed this as a bug in trac. Please contribute there with any helpful information related to this issue, thanks.

    http://core.trac.wordpress.org/ticket/19676

  13. Bozz
    Member
    Posted 2 years ago #

    I tried this on a clean install of WordPress with Twenty Eleven and could not replicate this. It must be either a plugin or theme conflict.

    dd32 from Trac says

    "This sounds like a plugin conflict to me, Probably something hooking into the pre_get_posts filter and modifying all Requests (including the one that builds the menu). "

    I noticed above someone else had Mailpress installed. I installed the most recent version of this on the same clean WP install and did not get any errors. Any ideas?

Topic Closed

This topic has been closed to new replies.

About this Topic