title: Create a wordpress Shortcode to display category posts
body: <p>Here is what I have so far. I'm in no way a great programmer. Just a front end guy trying to get this to work. I have a website with different blog categories. For example I have a category called: foods, places, things. I'm trying to write a function where I can execute a shortcode like this:</p>
  
  <blockquote>
    <p>[list_post mycat="foods"]</p>
  </blockquote>
  
  <p>Basically I want it to be flexible so whatever category I put inside of "mycat" it will display those blogs. </p>
  
  <p>Again any help would be really appreciated. I know I need to pass a parameter, but I'm honestly unsure how. This is my best effort. Thanks for any hekp </p>
  
  <pre><code>    $args = array(
      //Pass parameter here
      //Something like array (
          //$mycat =&gt; 'slug';
      //);
  
      );
  
  function list_post($mycat){
  
  
      $query = new WP_Query(array('category_name' =&gt; $mycat));
      if($query-&gt;have_posts()):
          while($query-&gt;have_posts()):the_post();
              the_title();
          endwhile;
      else:
          echo "No posts found!";
      endif;
      wp_reset_postdata();
  }
  
  add_shortcode('list_post', 'list_post')
  </code></pre>