I'm trying to pull in posts in a page that are tagged with the same page title. For example, if the page is called Banana Pants, then I can call all associated posts manually like this:
<?php
query_posts( array(
'tag_slug__in' => array('Banana Pants')
));
while (have_posts()) : the_post (); ?>
However, I'd like to do this automatically. When I try to place it as a variable, it doesn't work:
<?php
var $project_title = the_title();
query_posts( array(
'tag_slug__in' => array($project_title)
));
while (have_posts()) : the_post (); ?>
What am I doing incorrectly? Or, is there a better method?