Problem with Wp Query

0

I have a problem with the loop when I make a wp_query. See my code:

$query_video = new WP_Query( $args );
$args = array(
    'post_type' => 'post',
    'category_name' => 'videos',
    'posts_per_page' => '4',
    'orderby' => 'rand'
);

<?php if( $query_video->have_posts()) : while( $query_video->have_posts()) : $query_video->the_post(); ?>

What I'm trying to do:

  • Bring only 4 random posts from the Videos category.
  • This category of videos is of the Post-Format Video type (I think this does not influence much, since I'm trying to bring everything from the videos category.

Only he is not showing my loop! Could you give me a help?

    
asked by anonymous 22.02.2015 / 15:30

1 answer

1

You have to load the $ args variable before creating a new WP_Query. Just change the order and put $ args and then $ query_videos.

    
22.02.2015 / 23:44