Title: Problems with wp_query
Last modified: August 21, 2016

---

# Problems with wp_query

 *  [alemao85](https://wordpress.org/support/users/alemao85/)
 * (@alemao85)
 * [13 years ago](https://wordpress.org/support/topic/problems-with-wp_query-1/)
 * Hello,
    All my posts have tags. Now I want to select all posts that have certain
   tags and display 4 of them. In string I have my tags “tag1+tag2+tag”. This part
   works, but it always shows all posts with the specified tags and not only 4. 
   Ideally I would want to show 4 random posts that have the specified tags.
 * $featuredPosts = new WP_Query(‘post_count=2’);
    $featuredPosts->query(“tag=$string”);
   while ($featuredPosts->have_posts()) : $featuredPosts->the_post(); ?> . . .
 * Can anyone please help me?
 * Thanks!

Viewing 1 replies (of 1 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [13 years ago](https://wordpress.org/support/topic/problems-with-wp_query-1/#post-3697158)
 * Have you tired reviewing [http://codex.wordpress.org/Function_Reference/WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query)

Viewing 1 replies (of 1 total)

The topic ‘Problems with wp_query’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [13 years ago](https://wordpress.org/support/topic/problems-with-wp_query-1/#post-3697158)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
