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 ofpage-1
.get_the_title()
pulls the current page title – so you’re passingPage 1
to a parameter that expects a slugpage-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
.