Support » Fixing WordPress » Custom Menu Not Displaying on '404 Error' Page.

  • Resolved mmattner


    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');
    $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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • 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 “”. 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.

    I can confirm that the menu shows up when adding four numbers to the end, as in your example “” 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, “” 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.

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

    Still hunting…

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

    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.

    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.

    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?

    Yup, I had the exact same problem.

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

    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

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

    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?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Custom Menu Not Displaying on '404 Error' Page.’ is closed to new replies.