Title: conditional error based on category?
Last modified: August 20, 2016

---

# conditional error based on category?

 *  [Randall Duley Jr](https://wordpress.org/support/users/randall-duley-jr/)
 * (@randall-duley-jr)
 * [13 years, 2 months ago](https://wordpress.org/support/topic/conditional-error-based-on-category/)
 * Apologies first for what is likely a dumb question. I’m new to WordPress and 
   PHP so I’m already over my head. It concerns this part of the code:
 *     ```
       if ( count( $this->catlist->lcp_categories_posts) == 0 )
       {
           $lcp_display_output .= '<li>No results</li>';
       }
       ```
   
 * I just need a different error when there is no results **but** when in a particular
   category (‘news’). I modifyied the error code but I’m getting identical results.
 *     ```
       if ( count( $this->catlist->lcp_categories_posts) == 0 )
       {
           if ( in_category( 'news' )) {
               $lcp_display_output .= '<li>No news results</li>';
           } else {
               $lcp_display_output .= '<li>No results</li>';
           }
       }
       ```
   
 * I’m trying to filter the error but it doesn’t seem to evaluate the category at
   all. I always defaults to the last ‘else’ result.
 * I could really use some help…sigh.
 * [http://wordpress.org/extend/plugins/list-category-posts/](http://wordpress.org/extend/plugins/list-category-posts/)

The topic ‘conditional error based on category?’ is closed to new replies.

 * ![](https://ps.w.org/list-category-posts/assets/icon-256x256.png?rev=2517221)
 * [List category posts](https://wordpress.org/plugins/list-category-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/list-category-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/list-category-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/list-category-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/list-category-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/list-category-posts/reviews/)

## Tags

 * [category](https://wordpress.org/support/topic-tag/category/)
 * [conditional](https://wordpress.org/support/topic-tag/conditional/)

 * 0 replies
 * 1 participant
 * Last reply from: [Randall Duley Jr](https://wordpress.org/support/users/randall-duley-jr/)
 * Last activity: [13 years, 2 months ago](https://wordpress.org/support/topic/conditional-error-based-on-category/)
 * Status: not resolved