Is it possible to use a variable for the
I have three pages: red, yellow, and blue. I have multiple posts that are categorized in three categories: red, yellow, and blue. On the red page, I wish to display information from the posts in the red category; the same goes for yellow and blue.
I can do this easily if I create three different page templates with these
$args at the beginning of the loops:
$args = array( 'category_name' => 'red' ); $the_query = new WP_Query( $args );
'category_name' => 'yellow'
'category_name' => 'blue'
Rather than make three separate page templates, is it possible to create one, in which the
'category_name' parameter is set to the page's title (so the 'red' page would result in 'red' being dynamically set to the
While this doesn't work, hopefully it illustrates what I'm trying to do:
$title = the_title() $args = array( 'category_name' => $title );
Thanks for taking the time to look at this!