title: Displaying posts only form a category that has same name as the current page
body: <p>My theme supports different post types - one of those is portfolio posts. I'm trying to display portfolio posts on a page but only from one specific category - the one that has the same name as the current page.</p>
  
  <p>Example:<br>
  I have portfolio posts in categories: red, green, blue.<br>
  I have pages named: red, green, blue.
  Now I would like to display on page "red" only post from category "red".</p>
  
  <p>I'm very new to wordpress and making websites in general.</p>
  
  <p>I tried to read a bit about it and found a way to display posts from certain category only:</p>
  
  <pre><code>&lt;?php $the_query = new WP_Query( 'portfolio_category=red' );?&gt;
  </code></pre>
  
  <p>From there I tried to do this but it doesn't work:</p>
  
  <pre><code>&lt;?php $the_query = new WP_Query( 'portfolio_category=$pagename' );?&gt;
  </code></pre>
  
  <p>Here is full code of the page template I'm talking about:
  <a href="http://pastebin.com/LxetTnUz" rel="nofollow noreferrer">http://pastebin.com/LxetTnUz</a></p>