Większość użytkowników WordPress nadal używa kategorii by ewidentnie oznaczyć przynależność danego wpisów do konkretnej tematyki. Zdarza się, że tą odrębność chcemy dodatkowo podkreślić odmiennym kolorem tytułu, innym tłem itp. Czasami chcemy, by posty z danej kategorii nie miały daty publikacji albo możliwość ich komentowania była całkowicie zablokowana.
Osiągnięcie tego jest znacznie prostsze, niż by się mogło wydawać, jednakże wymaga trochę pracy [nic nie przychodzi łatwo ;)].
Zajmiemy się plikiem index.php, jednakże tą samą procedurę możemy powtórzyć w pliku single.php.
Tak wygląda the_loop z defaultowego theme Kubrick:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?> by <?php the_author() ?></small>
<div class="entry"> <?php the_content(’Read the rest of this entry &raquo;’); ?> </div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(’No Comments &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?></p>
</div>
<?php endwhile; ?>

Najpierw musimy wprowadzić wariacje zależne od kategorii. Używamy do tego funkcji in_category(’ID’), gdzie ID zastępujemy numerem kategorii, której będzie dotyczyła ta wariacja. Następnie w pliku style.css należy dodać niezbędną stylizację (np. inny kolor czcionki, tła itd.)
Przykład #1
W kategorii koty (ID=2) posty będą pozbawione nazwiska autora, a ponadto zamiast całego postu, będzie się wyświetlało tylko streszczenie. Nasz the_loop powinna wyglądać tak (wytłuszczonym drukiem zaznaczyłam, co się zmieniło):

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( in_category(’2′) ) { ?>
<div class="koty" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?></small>
<div class="entry"> <?php the_excerpt(); ?> </div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(’No Comments &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?></p>
<?php }
else { ?>

<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?></small>
<div class="entry"> <?php the_content(’Read the rest of this entry &raquo;’); ?> </div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(’No Comments &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?></p>
<?php } ?>
</div>
<?php endwhile; ?>

Przykład #2
W kategorii Pratchett (ID=3) tytuł posta ma mieć kolor zielony (#006633), a informacje przy komentarzach mają mieć inną treść:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( in_category(’3′) ) { ?>
<div class="terry" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?></small>
<div class="entry"> <?php the_excerpt(); ?> </div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(‘Brak reakcji &#187;’, ‘1 reakcja &#187;’, ‘% akcji ;) &#187;’); ?></p>
<?php }
else { ?>
<div class="post" id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time(’F jS, Y’) ?></small>
<div class="entry"> <?php the_content(’Read the rest of this entry &raquo;’); ?> </div>
<p class="postmetadata">Posted in <?php the_category(’, ‘) ?> | <?php edit_post_link(’Edit’, ”, ‘ | ‘); ?> <?php comments_popup_link(’No Comments &#187;’, ‘1 Comment &#187;’, ‘% Comments &#187;’); ?></p>
<?php } ?>
</div>
<?php endwhile; ?>

W style.css dodajemy:
.terry h2 {
color: #006633;
}

Jeśli chcemy ostylować więcej kategorii to wariacje w the_loop powinny wyglądać np. tak:

<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php if ( in_category(’2′) ) { ?>
<div class="koty" id="post-<?php the_ID(); ?>">
…ble-ble-ble…
<?php }
elseif (in_category(’3′)) { ?>
<div class="terry" id="post-<?php the_ID(); ?>">
…ble-ble-ble…
<?php }
elseif (in_category(’4′)) { ?>
<div class="books" id="post-<?php the_ID(); ?>">
…ble-ble-ble…
<?php }
else { ?>
<div class="post" id="post-<?php the_ID(); ?>">
..ble-ble-ble…
<?php } ?>
</div>
<?php endwhile; ?>

I tyle. Proste i skuteczne, choć trzeba się trochę pobawić ;).