Hello All,
I have this function I created to give my wordpress site a body tag...
function give_body_class( $print = true )
{
global $wp_query;
$c = "";
// Generic semantic classes for what type of content is displayed
is_archive() ? $c = 'archive_page' : null;
is_date() ? $c = 'date_page' : null;
is_search() ? $c = 'search_page' : null;
is_paged() ? $c = 'paged_page' : null;
is_tree(2) ? $c = 'type_1' : null;
is_tree(42) ? $c = 'type_2' : null;
is_tree(55) ? $c = 'type_3' : null;
is_tree(57) ? $c = 'type_4' : null;
is_home() ? $c = 'front' : null;
is_404() ? $c = 'error_404' : null;
return $print ? print($c) : $c;
}
I use this to print out the body class name in the header which is why I'm telling it to print.
And I am also trying use a logical statement on another page which is working, however I'm not sure how to stop it printing the variable.
e.g
<?php if (give_body_class('type_1')) { echo 'active'; } ?>
returns:
"type_1active"