Title: PixelDrake's Replies | WordPress.org

---

# PixelDrake

  [  ](https://wordpress.org/support/users/pixeldrake/)

 *   [Profile](https://wordpress.org/support/users/pixeldrake/)
 *   [Topics Started](https://wordpress.org/support/users/pixeldrake/topics/)
 *   [Replies Created](https://wordpress.org/support/users/pixeldrake/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/pixeldrake/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/pixeldrake/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/pixeldrake/engagements/)
 *   [Favorites](https://wordpress.org/support/users/pixeldrake/favorites/)

 Search replies:

## Forum Replies Created

Viewing 3 replies - 1 through 3 (of 3 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[CataBlog] [Plugin: CataBlog] Category Item Counts in php](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/)
 *  Thread Starter [PixelDrake](https://wordpress.org/support/users/pixeldrake/)
 * (@pixeldrake)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/#post-3066848)
 * Anywhere you want the menu button to appear on your page really. Below is the‘
   menu’ template, which should explain things a bit better.
 * `<a href="index.php?page=localstock&category=%CATEGORY%#Selection"><div class
   ="btnLocalStock"><img src="images/png%CATEGORY%.png" /><br />%CATEGORY%</div>
   </a>`
 * The ‘selected’ template is basically the same but minus the hyperlink and with
   a different image/class.
 * The php in my previous post determines if it will display a ‘menu’ or ‘selected’
   template based on the current $page. Then using the catablog_show_items() function
   with a single post limit, it displays a single copy of the template if there 
   are any items in that category.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[CataBlog] [Plugin: CataBlog] Category Item Counts in php](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/)
 *  Thread Starter [PixelDrake](https://wordpress.org/support/users/pixeldrake/)
 * (@pixeldrake)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/#post-3066838)
 * Well I got my dynamic menu working, though not in a very conventional manner 
   haha.
 * After many failed attempts at more complex solutions I realised I could just 
   make custom templates that would act as the buttons themselves.
 * Here is the php I use to display each button in case it helps anyone else:
 * <? if ($category == ‘Boats’) {catablog_show_items(boats, selected, menu_order,
   ascending, IN, 1, false);} else {catablog_show_items(boats, menu, menu_order,
   ascending, IN, 1, false);} ?>
 * One template is called ‘selected’ and represents the currently selected category.‘
   menu’ is the other template, which includes a hyperlink. I use the %CATEGORY%
   tag in the templates to fill out the button label, category img src and hyperlink.
 * It’s a bit hacky, but hey it works! The biggest problems are that these ‘buttons’
   now share the catablog-catalog style with the actual catalog items, and that 
   it uses capitals in the %CATEGORY% tag.
 * I’d still love to know if there’s an easier way to do this though, as this method
   is a bit… special.
 * Thanks again for your responses Mbrsolution.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[CataBlog] [Plugin: CataBlog] Category Item Counts in php](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/)
 *  Thread Starter [PixelDrake](https://wordpress.org/support/users/pixeldrake/)
 * (@pixeldrake)
 * [13 years, 7 months ago](https://wordpress.org/support/topic/plugin-catablog-category-item-counts-in-php/#post-3066832)
 * Hey Mbrsolution,
 * Thanks for your reply. To be a bit more specific, this is what I’m trying to 
   do:
 * <? if ($categoryquantity >= ‘1’) echo(‘example text’); ?>
 * So that example text only appears if there is at least one item in the specified
   category. I just can’t figure out a way to count the number of items in a category
   and make it a variable.
 * The website I’m developing does not contain many of the standard wordpress elements
   like a side bar. The catablog categories are accessed via a panel of custom buttons.
   I’d like to use similar php to the above so the buttons only appear for categories
   that have items in them. The items in this catalog are constantly changing and
   among the 5 categories there will often be a few empty ones that I’d rather not
   have displayed.
 * Thanks again for your time, I hope this is all making sense!
 * Regards,
 * Will

Viewing 3 replies - 1 through 3 (of 3 total)