• I need on the archives page to have a specific Category ID in the body ID.

    Currently
    i am using a specific header.php just for the archieves and have this as the body..

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

    Which prints <body class=”archive category category-adverts”> on the archive page

    So has the adverts category as adverts, but it would be handy if that could be the cat ID rather than name?

    Even better if it could be the just parent category ID as i only have 2 parent categories, just with lots of child ones?

    But the main cat would work fine..

    Can this be done?

Viewing 1 replies (of 1 total)
  • Thread Starter jezthomp

    (@jezthomp)

    Following on from that i have found this…

    <?php // dynamic body IDs
    
    function dynamicBodyID() {
    
    	if (is_home()) {
    
    		echo ' id="home"';
    
    	} elseif (is_single()) {
    
    		echo ' id="single"';
    
    	} elseif (is_search()) {
    
    		echo ' id="search"';
    
    	} elseif (is_archive()) {
    
    		echo ' id="archive"';
    	}
    }
    ?>

    Which goes in the functions.php

    And this in the header.php

    <body<?php dynamicBodyID(); ?>>

    How can i add to the functions one above…. if say cat ID 10 print id=”whatever”?

    Can that be done?

Viewing 1 replies (of 1 total)

The topic ‘Body ID/Class with Category ID?’ is closed to new replies.