I am using wordpress as a backend for my existing website. I have equipment that I am selling and each item is a post. I want to be able to query wp for listings and then discern the category ID and have all my items listed by there category. The results of what I've done so far are here: Each category has similar code. The problem of doing it this way is that all of the blank categories are displayed. I don't want the blank categories to show. What to do?
This is done making multiple queries and hardcoding the titles to each section like this:
<!-- Telephone Category -->
<?php $phone = new WP_Query();
$phone->query('showposts=10&cat=25'); //Telephone
if ($phone->have_posts()); ?>
<h2>Telephone</h2>
<table id="equip-table">
<tr>
<th style="width: 385px">Item Description</th>
<th style="width: 39px">Quantity</th>
<th style="width: 15px;"> </th>
<th style="width: 60px; text-align: center;">
Price</th>
</tr>
</table>
<!-- Telephone Query -->
<?php
while ($phone->have_posts()) : $phone->the_post();
get_post_meta($post->ID, 'Price', true); ?><?php get_post_meta($post->ID, 'Quantity', true);
?>
<div>
<table id="equip-table">
<tr>
<td style="width: 385px;">
<a href="<?php the_permalink() ?>"><?php the_title(); ?>
</a></td>
<td style="width: 39px"><?php echo get_post_meta($post->ID, 'Quantity', true); ?>
</td>
<td style="width: 15px;">$</td>
<td style="width: 60px; text-align: right;">
<?php echo get_post_meta($post->ID, 'Price', true); ?>
</td>
</tr>
</table>
</div>
<?php endwhile; ?><br />
<!-- End Telephone Category -->