Title: adding category to &quot;if no posts&quot;
Last modified: August 31, 2016

---

# adding category to "if no posts"

 *  [rudtek2](https://wordpress.org/support/users/rudtek2/)
 * (@rudtek2)
 * [10 years ago](https://wordpress.org/support/topic/adding-category-to-if-no-posts/)
 * I have a custom post type with custom categories. I’ve created a custom taxonomy
   page for the categories as well. I want to have a line of code that will say “
   we’re sorry we dont have any [categoryname] at the moment.”
 * this error code would list the actual category name though. so if the user were
   on “product_category/topicals/” it would say “we’re sorry we dont have any topicals
   at the moment.”
 * i put this code at the end of my lopp after the end while. but it’s AFTER my 
   loop so it doesn’t show a category
 *     ```
       <?php
       endwhile;
       else :
       // If no content, include the "No posts found" error.
       echo "<h1 class='center'>We currently don't have any selection of this type available.</h1><p class='center'>Please check back soon!</p>";
       endif;
       ?>
       ```
   
 * is there any way to do this?

The topic ‘adding category to "if no posts"’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [rudtek2](https://wordpress.org/support/users/rudtek2/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/adding-category-to-if-no-posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
