Title: wscheer's Replies | WordPress.org

---

# wscheer

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

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

 Search replies:

## Forum Replies Created

Viewing 1 replies (of 1 total)

 *   Forum: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
   
   In reply to: [category names that are to long don’t work in wp_query()](https://wordpress.org/support/topic/category-names-that-are-to-long-dont-work-in-wp_query/)
 *  Thread Starter [wscheer](https://wordpress.org/support/users/wscheer/)
 * (@wscheer)
 * [17 years ago](https://wordpress.org/support/topic/category-names-that-are-to-long-dont-work-in-wp_query/#post-1167274)
 * Actually, I found a fix.
    Instead of using “cat_name” you can use “category_nicename”.
   The nice name is the category slug. IE: Condos & Beach Houses -> condos-beach-
   houses There seems to be no issue with length using the slug.
 * I have highlighted the change below with =================
 *     ```
       <?php //get the current category and put into $category var
       $category = get_the_category();
       echo "<h2 class='headline'>".$category[0]->cat_name."</h2>";
       //
       //
       // ==========================================
       $cat = $category[0]->category_nicename;
       // ==========================================
       //
       //
       ?>
   
       <?php $recent = new WP_Query(); ?>
   
       // for testing what the 'get_the_category()' output was
       <?php echo "cat: ".$cat; ?>
   
       // this was working for some categories but not others
       <?php $recent->query('category_name='.$cat.'&showposts=-1'); ?>
   
       <?php while($recent->have_posts()) : $recent->the_post(); ?>
       <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><br />
       <?php endwhile; ?>
       ```
   
 * Hope that helps someone

Viewing 1 replies (of 1 total)