Plug-ins for Pulse

Pulse Script icon

Body Class

version 1.0

Body Class is a PHP script to add class styles to the body tag of your page based on the current page state. It is based on the same principles as the WordPress body class but has been created specifically for Pulse. It easily allows you to target and style specific pages or blog posts within the CMS.

What does the script do?

The script will output class styles to the page based on the environment the page is viewed in.
At present the script will add the following class styles to the page;

  • The page name/slug - home for example
  • The page type - page, blog, blog-home, single-post
  • The blog post ID - postid-3
  • The blog post date - day-10, month-5, year-2016
  • Is the admin logged in? - logged-in
  • Is this the 404 page? - error404
  • The current page template - page-template-default

Below is an example showing the class styles for a page after the script has been applied to the Pulse template.

<body class="work page logged-in page-template-default">

With these styles applied to the body tag it is very easy to style your Pulse site depending on where the user is and what sort of page they are looking at. You could, for example, style the page differently if the admin is currently logged into Pulse or adjust the layout of the template specifically for single posts.

For example;

body.logged-in { outline:1px solid #f00 }

Installing the script

Download the PHP script and FTP the file into your Pulse install at inc > tags.
Open up your template and add the following code to the top of the file (anywhere before the body tag will do).

<?php include_once("inc/tags/body-class.php"); ?>

Lastly locate the body tag in your template and edit it so it looks like the one below;

<body<?php body_class(''); ?>>

Script options

The body_class function accepts two parameters;

  1. extra-classes - add any extra classes to the body tag by simply adding them here.
  2. raw - if you just want the class names output without the class="" then append true as a second parameter to the function.

<body class="<?php body_class('foo bar baz',true); ?>">

Body Class

Version 1.1
Requires Pulse 4.0 or above
Last Updated 19th August 2015

Need something else? We can help.


If you are looking for a custom plug-in, template or gallery for Pulse then get in touch as I'm sure we can help.