title: Dynamically call categories into WordPress template based on page name
body: <p>Agh this is frustrating. I've been searching for hours on how to do this.</p>
  
  <p>I am creating a WP template that pulls in queries of a category on the page. </p>
  
  <p>My question is how can I make the category in the array dynamically load, whether by slug or whatever, based entirely on what the page title is?</p>
  
  <p>The fancy piece is that it will be three sections on the page via an additional category that also need to be loaded in the template, but those are not dynamic. </p>
  
  <p>So if I can break this down:</p>
  
  <p>Section 1 - TitleCat + Section1Cat</p>
  
  <p>Then</p>
  
  <p>Section 2 - TitleCat + Section2Cat</p>
  
  <p>Then</p>
  
  <p>Section 3 - TitleCat + Section3Cat</p>
  
  <p>That way during content creation, my team can simply click two categories, and the website will automatically put the post excerpts where it needs to go!</p>
  
  <p>It needs to be dynamic so I don't need to build a template for each of the 31 categories the posts are divided into.</p>
  
  <p>EDIT: This is how I was approaching it using ACF. That array can be simply switched out for categories if that's the way to go. Same concept.</p>
  
  <pre><code>&lt;?php $pagecat = $post-&gt;post_title; //this copies the page title the page title ?&gt;
  
  &lt;?php 
  
  // args
  $args = array(
    'posts_per_page' =&gt; 4,
    'meta_query' =&gt; array(
      'relation' =&gt; 'AND',
      array(
        'key' =&gt; 'page',
        'value' =&gt; $pagecat,
        'compare' =&gt; '='
      ),
      array(
        'key' =&gt; 'section',
        'value' =&gt; 'Second String',
        'compare' =&gt; '='
      )
    )
  );
  
  $the_query = new WP_Query( $args ); 
  
  ?&gt;
  </code></pre>