title: WordPress: WP_Query in functions.php returns empty query (for a custom shortcode)
body: <p>I'm writing a custom shortcode for a childtheme that I've dropped into my child themes functions.php. Here's the code:</p>
  
  <pre><code>function get_featured_video(){
  $video_query = new WP_Query('category_name=videos&amp;order=ASC');
  $videoPath = "/";
  $videoText =  "";
  while ($video_query-&gt;have_posts()){
      $video_query-&gt;the_post();
      $featured = get_post_meta($post-&gt;ID, "vid_feature", $single = true);
      if(strtolower($featured)=='yes'){
          $videoPath = get_permalink($post-&gt;ID);
          $content = strip_tags($post-&gt;post_content);
          $contentArr = str_word_count($content,1);
          if(count($contentArr&gt;50)){
              $videoText = join(" ",array_slice($contentArr,0,50));
              $videoText .= " &lt;a href='$link'&gt;&amp;lt;read more&amp;gt;&lt;/a&gt;";
          } else {
              $videoText = $content;
          }
          break;
      }
  }
  $returnStr = "&lt;h1&gt;&lt;a href='$videoPath'&gt;You've Got to See This!&lt;/a&gt;&lt;/h1&gt;\n";
  $returnStr .= $videoText;
  return $returnStr;
  }
  
  add_shortcode('getfeaturedvideo','get_featured_video');
  </code></pre>
  
  <p>The problem I'm having is that it's returning a blank query. I know there's a post in the videos category. I've never used the WP_Query inside functions.php. Is there a different method I need to use?</p>