• Hello All,

    I’ve searched high and low, but can’t seem to find an answer..

    I need to keep posts categorized as ‘News’ separate from posts categorized as ‘Blog’ as well as be able to style the single page templates and archive pages for each differently.

    I have successfully created the two pages (‘News’ and ‘Blog’) that display the correct category content and if you click on either a ‘News’ OR ‘Blog’ post I am using the following code to send them to the correct single page template:

    <?php
    	if ( in_category('10') ) {
    	include(TEMPLATEPATH . '/single_blog.php');
    
    	} else {
    	include(TEMPLATEPATH . '/single_news.php');
    }
    ?>

    HOWEVER, if I click on ‘News’, even though it is going to the correct single page template, the body tag still displays: <body class="blog"> which doesn’t allow me to style it as being in the ‘News’ section. If I click on a post in either category the body tag displays <body class="single"> which doesn’t allow me to style posts as either ‘News’ or ‘Blog’.

    How can I add the category to the body tag? OR is there a better way to do this?

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Unless you provide a link to a page demonstrating the problem, no one will be able to offer much in the way of specific help.

    Thread Starter circleatseven

    (@circleatseven)

    While it is client work that I am not able to share — I thought I explained my situation clearly and asked a simple question in the end:

    How can I add the category to the body tag? OR is there a better way to do this?

    Maybe not?

    Either way.. I found a work around.. and for the chance this will help someone – Instead of attempting to add a body class e.g. <body class="..."> … I was able to filter out unwanted categories from showing up in the wrong sections with the following code:
    <?php query_posts($query_string . '&cat=-10'); ?>

    If its not obvious, you would replace the number ’10’ with whatever category ID you’d like to exclude… And place this before the loop.

    Enjoy.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Different post categories as different pages’ is closed to new replies.