WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Removing parameters that body_class() returns - Custom page template (10 posts)

  1. 220yards
    Member
    Posted 2 years ago #

    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

  2. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  3. 220yards
    Member
    Posted 2 years ago #

    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

  4. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  5. 220yards
    Member
    Posted 2 years ago #

    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

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    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.

  7. 220yards
    Member
    Posted 2 years ago #

    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/

  8. alchymyth
    The Sweeper & Moderator
    Posted 2 years ago #

    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:

    http://www.transformationpowertools.com/wordpress/twenty-eleven-new-page-template-with-sidebar-correction

  9. 220yards
    Member
    Posted 2 years ago #

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

  10. defeated
    Member
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic