1 of 2
deflime
  • 888
  • 7
  • 9

Try $cat_name = $category->slug instead of $cat_name = $category->name.

You are also missing wp_reset_postdata(); just after endwhile;.

deflime
  • 888
  • 7
  • 9