• Resolved Camille

    (@kyameel)


    Hi, I’m really new with PHP so I don’t know how to go about doing this.

    What I want to do:
    I have 2 main categories, (1)Prose and (2) Poetry. And each have their own sub categories.

    I want to style the 2 main categories differently, and their sub categories following suit of their own parents. And the styling can be done by calling a new css OR just change the defining div id.

    (e.g. from

    <div id="cat-prose"> to <div id="cat-poetry">

    or something like that)

    The sub-categories will be added in due time, so I don’t want to painstakingly add more category-#.php into the theme. Is there a way to do this with just one category.php file and only do queries?

    I’ve seen a lot of support questions tackling different styles/ themes for different categories. But I couldn’t find the one I need. Any help will be much appreciated.

    Thank you very much

Viewing 5 replies - 1 through 5 (of 5 total)
  • Samuel B

    (@samboll)

    Thread Starter Camille

    (@kyameel)

    Hi, samboll.

    Yes, I tried reading it but couldn’t understand it ^^; all I could gleam from it are making menus on the page.

    Like I said, I’m new with PHP and could only understand bits and pieces.

    Thread Starter Camille

    (@kyameel)

    Here’s my current code.

    I know I’m doing something wrong, I just don’t know what. ^^; I’m still trying to understand this language ^^;

    <?php
    /*
    Template Name: Template - Category
    */
    ?>
    
    <?php get_header(); ?>
    <?php get_sidebar(); ?>
    
       <?php if (have_posts()) : ?>
       <?php $this_category = get_category($cat);?>
        <!-- MAIN CONTENT -->
        <div id="wrapper">
        <?php if ($this_category->category_parent == 3) { ?>
        <div id="cat-prose">
    
        <?php } else { // Do something else ?>
        <div id="cat=poetry">
    
        <?php while (have_posts()) : the_post(); ?>
                 <h2><?php single_cat_title(); ?><?php the_title(); ?></span></h2>
                 <div class="content-entry">
                 <ul>
                     <li><a href="<?php the_permalink() ?>" title="View Image "><?php the_excerpt(); ?></a></li>
    
    <?php endwhile; ?>
                </ul>
                 <div id="clear">&nbsp;</div>
    		<div class="navigation">
    			<div class="alignleft"><?php next_posts_link('&laquo; Older Pinups') ?></div>
    			<div class="alignright"><?php previous_posts_link('Newer Pinups &raquo;') ?></div>
    		</div>
    
    	<?php endif; ?>
                </ul>
                <div id="clear"></div>
            </div>
    
            <h3>&nbsp;</h3>
    
        </div>
        </div>
        <!-- END MAIN CONTENT -->
    
    <?php get_footer(); ?>
    Thread Starter Camille

    (@kyameel)

    It’s okay! I finally found exactly what I was looking for.

    For reference, here it is

    I guess, I wasn’t looking hard enough.

    Thank you!

    Is there a way to get this to affect posts on the mainpage?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Same style for a parent category and it’s child, but different for the rest?’ is closed to new replies.