PhP question with categories
-
I’m using a mimbo2.1 theme layout (http://www.darrenhoyt.com/demo/mimbo2/) and there is a section of it called “rightcolumn” which has little blurbs pop up (it is on the lower right hand side of the screen, titles “Gadgets” “Music” and “Style.”)
The PhP code that makes these pop up (shown below), puts my categories into an array and lists the most recent posts in each of these categories, having them show up one by one with a possible image (put on through the Custom Fields sections). What I would like to do is have each of these little blurbs show up linking to a category template page, for example, as the first category is 23, I want it to just link to category 23 and the dynamic content I have loaded onto category-23.php, with a static description and an image that doesen’t change unless I manually change it. While I like the dynamic PhP content…I want that to be on the category-x.php pages that each of those blurbs would eventually link to.
What I would very much like to know is, short of removing the code from that section and manually doing the html to just link to these categories, what would be the best way to modify the php code below to have each blurb link to a category page instead of the most recent post written?
I really appreciate the help!!!!!
Thank you!
<div id=”rightcol”>
<?php
// this is where you enter the IDs of which categories you want to display
$display_categories = array(23,24,21,19,20);
foreach ($display_categories as $category) { ?>
<div class=”clearfloat”>
<?php query_posts(“showposts=1&cat=$category”);
$wp_query->is_category = false;
$wp_query->is_archive = false;
$wp_query->is_home = true;
?>
<h3>“><?php
// this is where the name of each category gets printed
single_cat_title(); ?></h3>
<?php while (have_posts()) : the_post(); ?>
<?php
// this grabs the image filename
$values = get_post_custom_values(“Image”);
// this checks to see if an image file exists
if (isset($values[0])) {
?>
” rel=”bookmark” title=”Permanent Link to <?php the_title(); ?>”><img src=”<?php bloginfo(‘template_url’); ?>/images/<?php $values = get_post_custom_values(“Image”); echo $values[0]; ?>” alt=”” />
<?php } ?>
” rel=”bookmark” class=”title”><?php
// this is where title of the article gets printed
the_title(); ?>»<?php endwhile; ?>
</div>
The topic ‘PhP question with categories’ is closed to new replies.