WordPress.org

Support

Support » Themes and Templates » [Resolved] Removing parameters that body_class() returns – Custom page template

[Resolved] Removing parameters that body_class() returns – Custom page template

  • Hi,

    I’m trying to sort the formatting of my new home page, and I think I know what I need to do, but can’t figure how to do it.

    I have a custom template for my home page, and somewhere it thinks it is both a singular page and two-column (code below). If I remove singular within the debug thing in chrome the page is perfectly formatted.

    <body class="home page page-id-128 page-template page-template-page-pop-php logged-in admin-bar singular two-column right-sidebar"

    Could anyone point me to where I can remove this from the custom template please. Or am I going about this all the wrong way?

    My website, totalxc.co.uk

    Thanks in advance

Viewing 9 replies - 1 through 9 (of 9 total)
  • esmi
    Forum Moderator

    @esmi

    Those classes are all correct. Your site is currently using a static front page (ie a single Page). You should be amending your CSS rather than trying to remove the body classes.

    Using a page was the only way I could figure out how to include a static intro, then a list of posts with excerpt and image.

    I tried (and failed) to work out what CSS to change before I discovered this ‘singular’ thing. Any guidance on which CSS to update would be great. I was worried that editing the CSS would mess up other pages. I’m not a programmer, just very patient at trial and error!

    Thanks

    esmi
    Forum Moderator

    @esmi

    If I remove singular within the debug thing in chrome the page is perfectly formatted.

    But we don’t know how the page is supposed to look, so we really need more details.

    Hi, I guess I want it to look like all the other static pages. Side bar on the right, text aligned on the left, not indented. I notice the other static pages do not have ‘singular’ in the ‘body class’ expression. Or to be precise, exactly like it looks if I remove ‘singular’ from the code using Chrome debug.!

    I guess my question is, why do I need to keep the ‘singular’ expression on the home page, if it is just messing up my formatting?

    Many thanks

    esmi
    Forum Moderator

    @esmi

    Because that’s what the body_class() function generates on a single post or page. It’s your CSS that you need to sort out.

    Right, found some CSS from the page below and I’m pretty much sorted. Thanks

    http://tricksmommy.com/2011/07/08/add-sidebar-in-single-post-pages-of-twenty-eleven-wordpress-theme/

    Michael
    Forum Moderator

    @alchymyth

    just to add:
    there is a way to remove body_classes with a filter;

    useful in Twenty Eleven child themes, if you want to add a sidebar to a custom page template without the need to change the css:

    Twenty Eleven – New Page Template with Sidebar Correction

    That is exactly what I was after, thanks so much.

    Thank you Alchymyth!

    This is something that WordPress need to fix. Making a 2 col custom template should be easy… and it’s not if you have to add individual template pages to the functions.php file. It’s messy.

    However, since it works that way I’m happy enough for now.

    @esmi, it’s not how it was supposed to look. If you use sidebar template you get what it should look like. But if you copy sidebar template and give it a new name it adds in singular to the body class (it’s not there when you use the original sidebar template). Hope it gets fixed in the next update.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Resolved] Removing parameters that body_class() returns – Custom page template’ is closed to new replies.