WordPress 2.8 body_class, automatic_feed_links

Template Tag body_class

The coming WordPress 2.8 provides a new Template Tag, body_class. This function gives the body element different classes, which gives you the possibility to use it effectively with CSS.

>

Like in the comment area and post classes, the WordPress-Developer get the best out of the database. Here an example if you open a page template “tutorial.php”:


All in all, there are following classes available:

  • rtl
  • home
  • blog
  • archive
  • date
  • search
  • paged
  • attachment
  • error404
  • single postid-(id)
  • attachmentid-(id)
  • attachment-(mime-type)
  • author
  • author-(user_nicename)
  • category
  • category-(slug)
  • tag
  • tag-(slug)
  • page-parent
  • page-child parent-pageid-(id)
  • page-template page-template-(template file name)
  • search-results
  • search-no-results
  • logged-in
  • paged-(page number)
  • single-paged-(page number)
  • page-paged-(page number)
  • category-paged-(page number)
  • tag-paged-(page number)
  • date-paged-(page number)
  • author-paged-(page number)
  • search-paged-(page number)

Template Tag automatic_feed_links

This function is in the function.php of the Default-Theme. automatic_feed_links() enables the automatic output of feed links in the header area of the document. This function is active by default, but you can turn it off, it won’t output any feed links anymore:

automatic_feed_links(false);//no output
automatic_feed_links();//no output

In single view there is the output of feed, comment feed and additionally the post-comment-feed.

WordPress 2.8 Feed


Posted

in

by

Comments

17 responses to “WordPress 2.8 body_class, automatic_feed_links”

  1. Danny Avatar

    The upcoming new version of Thematic Framework For WordPress will provide classes based on the browser, the version of the browser and the os where the page is running.
    I think this is really helpful for styling..

  2. […] New features in WordPress 2.7 regarding to body classes (i hope they won’t change the admin theme AGAIN) […]

  3. The Frosty @WPCult Avatar

    @Justin In Justin Tadlocks Hybrid theme that body class based on browser and OS is already built in. you can check it out @ Theme Hybrid.

  4. […] body_class(), otro tag para nuestros themes que especificará un buen listado de opciones sobre este atributo haciendo como hasta ahora venía haciendo el theme sandbox. […]

  5. […] to WordPress Themes include new functions and body classes, automatic_feed_links, and […]

  6. […] to WordPress Themes include new functions and body classes, automatic_feed_links, and […]

  7. Goedkope Avatar

    Nice … this will open up the ability to change the look of nearly everything with CSS only.

  8. […] komplette Liste der möglichen Klassen hat das Team von WP Engineer […]

  9. Matthew Hunt Avatar

    Drupal has been using this feature for a long time..I am going take a guess here that wordpress got the idea from Drupal.

  10. […] inutilmente appesantito. L’elenco completo delle classi stampate dalla nuova funzione è in questo post di […]

  11. Chris Avatar
    Chris

    Hi there… I really enjoyed the post and have had fun using the body_class() function–successfully–for the ‘home’, ‘single’ and ‘page’ classes. However, I’m trying to figure out how to use the function with “specific WP pages” and for some reason I can’t figure it out. In other words, how can I set up a body class that applies only to particular WP page (e.g. page ID 19)? Any help you can offer would be much appreciated. Thanks.

    Best, Chris

  12. Michael Avatar

    Chris, for a page i have the following output from body_class():

    page page-id-18 page-parent page-template page-template-default logged-in

    So you can use .page-id-18 in your stylesheet.

  13. gilly Avatar

    My site has been compromised and has spam urls inserted into the html on the home page.

    I have tried reinstalling, and if I delete the following code from the header theme it just reappears staight back.

    Here is the code as it appears before the spam urls in the html

    <div style=

    here is what i have deleted from the header theme

    <body >

    Can you please suggest how I solve this as its driving me mad?

  14. Osborne Brook Avatar

    This is very useful, makes our blog integrations so much easier. Is there any way to remove any of those ‘reserved’ class names though?

    Thanks!

  15. […] If you want to read more about body_class() you can take a look at this (quite old) post by wpengineer.com […]

  16. […] 2.8 and the body class function WordPress 2.8 body_class, automatic_feed_links 9 Ways to Set Dynamic Body IDs via PHP and […]