WordPress.org

Support

Support » Requests and Feedback » [Resolved] WordPress 3.2 body_class function is missing "page-template-default" class

[Resolved] WordPress 3.2 body_class function is missing "page-template-default" class

  • Hi,

    I just upgraded a site to 3.2 which made use of the CSS class “page-template-default” on all pages that had no page template selected. This class doesn’t seem to be rendered anymore on pages, although all other body classes seem fine.

    Is this deliberate or a bug?

    Thanks in advance for any help.

    Kyle Duncan

Viewing 7 replies - 1 through 7 (of 7 total)
  • Did you change your theme? Nothing in trac indicates this has been removed.

    Hi,

    No it was a custom written theme with this in header.php:

    <body <?php body_class( $class ); ?>>

    Before this generated “page-template-default” as one of the many classes on pages with no template selected. it used to look like this:

    <body class=”page page-id-10 page-template page-template-default”>

    now, on those pages, just the following is generated:

    <body class=”page page-id-10″>

    esmi

    @esmi

    Forum Moderator

    Why would you need “page-template-default” on the body element?

    Moderator Dion Hulse

    @dd32

    Lead Developer

    it used to look like this:

    <body class=”page page-id-10 page-template page-template-default”>

    now, on those pages, just the following is generated:

    <body class=”page page-id-10″>

    This was fixed back in 2.8.1, The class was never supposed to be added when no page template was specified. See [11567] and the ticket mentioned in that commit

    Moderator Dion Hulse

    @dd32

    Lead Developer

    Sorry scrap that, Yes, that caused a similar bug back in 2.8, however, that’s not what caused it.

    It was a bug that the page-template-default was ever shown. See #17458 for details.

    @kyleduncan If you want it back, adding this to your themes functions.php file will do so.

    function mytheme_body_class_template_default($classes) {
      if (is_page() AND !is_page_template()) { $classes[] = 'page-template-default'; }
      return $classes;
    }
    add_filter('body_class', 'mytheme_body_class_template_default');

    @esmi It’s a handy css hook to use if each page template has a very different layout.

    Thanks to all for the explanations.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘[Resolved] WordPress 3.2 body_class function is missing "page-template-default" class’ is closed to new replies.
Skip to toolbar