Adding a thumbnail to the results of wp_list_categories and other goodies
-
I’m trying to make my site more adaptable to change. Seeing as entering all the code by hand is simply not what the cool kids do, I need to figure out how to get things working automatically in PHP.
Right now, I’m listing all the subcategories of a certain category on my homepage in these pretty little boxes. It looks great, works how I’d like it to, brings the ladies to the bar, etc etc…
This is the code I have:
<a href="[category url]"> <?php $the_query = new WP_Query( 'cat=9&posts_per_page=1' ); while ( $the_query->have_posts() ) : $the_query->the_post(); if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail(); } endwhile; // Reset Post Data wp_reset_postdata(); ?> </a><BR> <h3>[category title]</h3> </div>
I have four of these at the moment, but may want more. or less. or change them entirely. Who knows what the future holds. Point being, I want this automated.
Right now I have this little gem that gives me a happy little list of all the subcategories in my category by doing this:
<?php wp_list_categories(array('child_of' => '8','style' => 'none')) ?>
However, I want to make this list pretty, and can’t seem to figure out how that can be done. I’m thinking it’s some sort of foreach instance but my syntax keeps getting flagged in my editor.
- The topic ‘Adding a thumbnail to the results of wp_list_categories and other goodies’ is closed to new replies.