• Resolved mrwweb

    (@mrwweb)


    If there are Menu Items published and a page with the slug “menu”, then the items appear half-formatted below the page body even if using the “Default Template”.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Kathryn Presner

    (@zoonini)

    Hi Mark, I haven’t been able to replicate this one so far. Is there an example of this online somewhere that I could take a look at?

    Or if not, would it be possible to show me a screenshot of what you’re seeing? Thanks!

    Thread Starter mrwweb

    (@mrwweb)

    Here are screenshots of the Menu page, Menu page edit screen, and the Menu posts: https://cloudup.com/ctR49DeQW9I

    You can see that despite using the default template, the items appears.

    I looked and see that the reason for this is that the theme does a big no-no of invoking the Template Hierarchy with a custom page template file name: page-menu.php. Named that way, the page gets used not just when the template is selected but when the page slug is “menu”.

    So this actually causes two problems, the second of which might actually be easier to solve:

    1. Page’s with the slug menu that use the default template display menu items.
    2. Pages with the slug menu that use the default template display poorly formatted menu items.

    The style.css uses a body_class that’s only there when the template is set for the page, so you get poorly formatted content for that slug-but-no-template issue. Short of including an update script to migrate people’s already-set templates, I’m not sure how you can solve this, but please let this be a lesson for the Automattic themers to be more careful with their template file names in the future!

    And even if you can’t fix #1, I’d consider fixing #2 (maybe register a custom body class if the slug is “menu” and add that to style.css) to support newer users that stumble into making the theme work without setting the Template. I suspect this group may be even larger than my edge-case client that doesn’t want the menu items shown on the “Menu” page.

    Moderator Kathryn Presner

    (@zoonini)

    Thanks for the details on this – very helpful. I’ll pass the report along to our developers and we’ll keep you posted here.

    Moderator Kathryn Presner

    (@zoonini)

    Mark – thanks again for the heads-up on this.

    Our developer took route #2 to avoid potentially disrupting existing sites. Food menu items on a page with the menu slug are now styled better and the fix will be included in the next update.

    In the meantime, you can get the fix by adding these lines in /inc/tweaks.php after line 35:

    // Adds a class to a page with default template and 'menu' slug
      if ( 'page' == get_post_type() && 'menu' == basename( esc_url( get_permalink() ) ) )
        $classes[] = 'page-template-page-menu-php';

    Or you can grab the file here: https://cloudup.com/cdtsAz286iw

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Bug on Page with "menu" slug’ is closed to new replies.