In the archive page for a custom post type I have this query:
$the_query = new WP_Query( array( 'category_name' => 'Bordeaux' ) );
Then in the loop I have:
if ($the_query->have_posts() );
The loop correctly searches my posts and displays all posts with the category 'Bordeaux' on the page.
I would like to alter this query so that instead of searching for the text string 'Bordeaux', it will query the title of the page and search for a category with that name.
This will allow me to have just one .php file for all custom post types, rather than individual ones.
I tried the following but it didn't work:
$the_query = new WP_Query( array( 'category_name' => echo the_title(); );
Any help much appreciated!