title: Show posts in Category with Tag (Wordpress)
body: <p>I am trying to display a lists of posts on a custom post template that are in a 'category' and that have a specific 'tag' that matches the title of the post.</p>
  
  <p>For example I have posts by city name,</p>
  
  <ul>
  <li>New York </li>
  <li>Chicago</li>
  <li>Texas</li>
  <li>...etc</li>
  </ul>
  
  <p>I then have several categories,</p>
  
  <ul>
  <li>News</li>
  <li>Events</li>
  <li>Classifieds</li>
  <li>...etc</li>
  </ul>
  
  <p>For every post I make to one of those categories I then assign a post tag that matches the name of the city. </p>
  
  <p>For example if I have a news item for New York, I select the 'News' category and assign the post the 'New York' tag.</p>
  
  <p>When I am on the custom post template page for New York I want to retrieve posts associated with the News category that have the tag name = New York (the title of the post).</p>
  
  <p>However my dilema is that I can not figure out how to dynamically generate the tag name from the title of the post. </p>
  
  <p>Eg.</p>
  
  <pre><code>    &lt;?php 
                              $tag = wp_title('', FALSE);
              query_posts( 'tag=' . $tag . '' );
  
              if ( have_posts() ) while ( have_posts() ) : the_post();
  
                      echo '&lt;li&gt;';
  
                          the_title();
  
                      echo '&lt;/li&gt;';
  
               endwhile; 
  
              wp_reset_query(); ?&gt;
  </code></pre>
  
  <p>But when getting the tag name using wp_title() it would print 'New York' with a space between the words 'New' and 'York'. This doesn't work.</p>
  
  <p>To get it to work it would need to be 'new-york' with the hyphen in place. But I can not figure out how to generate the tag name based on title with hyphens in place of spaces. </p>
  
  <p>I hope this makes sense.</p>
  
  <p>I appreciate any and all efforts in helping. </p>
  
  <p>Thank you.</p>