Do you have a category.php file in your theme? If so use that. If not, copy your theme’s index.php file and name the new file category.php. The past your new code just above thr start of the Loop – ie before:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
Thread Starter
virg
(@virg)
Amazing Esmi! It works! Thanks!! Do you know if I can style the font and the top margin of the text used to describe the category?
Try changing the code to:
<?php if (is_category('Category A')) { ?>
<p class="cat-text cat-a">This is the text to describe category A</p>
<?php } elseif (is_category('Category B')) { ?>
<p class="cat-text cat-b">This is the text to describe category B</p>
<?php } else { ?>
<p class="cat-text">This is some generic text to describe all other category pages,
I could be left blank</p>
<?php } ?>
That should allow you to style all incarnations of this static text using .cat-text and add category-specific style using .cat-a etc.
Thread Starter
virg
(@virg)
I’m sorry, I don’t understand. Do I do something like this?
.cat-text font-family: Helvetica, Arial, sans-serif;
I tried but nothing happens.
Try:
.cat-text {font-family: Helvetica, Arial, sans-serif;}
Thread Starter
virg
(@virg)
ooh ok! it works now. but in the meantime I decided to use as simpler code:
<p>Category: <?php single_cat_title(); ?></p>
It just posts the category name which I was doing manually with the former code. Now I’m trying to figure out how to put the
.cat-text font-family: Helvetica, Arial, sans-seri
in this one
<p class="cat-text">Category: <?php single_cat_title(); ?></p>
Thread Starter
virg
(@virg)
I really need to learn coding…!!!
I have:
<p class="cat-text {font-family: Georgia, Times New Roman, Times, serif;}">Category: <?php single_cat_title(); ?></p>
and nothing happens. The more I try to learn WP the more it scares me.
<p class="cat-text">Category: <?php single_cat_title(); ?></p>
goes in your template file.
.cat-text {font-family: Georgia, Times New Roman, Times, serif;}
goes in your stylesheet.