Custom category code not showing all posts

First off, ensure that the category is exactly the same name as the page ( slug and all ). Secondly, the parameters you’re passing to WP_Query is incorrect.

  • category_name expects a slug. For example, Page 1 would have a slug of page-1.
  • get_the_title() pulls the current page title – so you’re passing Page 1 to a parameter that expects a slug page-1.

What you can do is sanitize_title( get_the_title() ) or preferably you could declare global $post at the top of your document and pass instead $post->post_name.