Title: Filtering Posts
Last modified: August 20, 2016

---

# Filtering Posts

 *  [Bharath Gupta](https://wordpress.org/support/users/sribharath/)
 * (@sribharath)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/)
 * Hi,
 * I want to do some filtration to engage visitors for more time on my site
 * I want to show posts from a selected category and also with custom field
 * For ex :
 * I made a post saying **“tom cruise new movie “x”
    
    with custom field tom cruise
 * so behind the post i want to show posts containing the same custom field and 
   which are posted in gallery category
 * for this example it should show tom cruise galleries
 * Please help me
 * Thanks in advance
 * sribharath
    _[sig moderated as per the [Forum Rules](http://codex.wordpress.org/Forum_Welcome)]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2121832)
 * [http://codex.wordpress.org/Function_Reference/WP_Query](http://codex.wordpress.org/Function_Reference/WP_Query)
 *  Thread Starter [Bharath Gupta](https://wordpress.org/support/users/sribharath/)
 * (@sribharath)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2121839)
 *     ```
       $query = new WP_Query( 'tag=<?php $values = get_post_custom_values("customname"); echo $values[0]; ?>
       &cat=4' );
       ```
   
 * THATS iT ?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2121840)
 * No. Read the page the section on custom fields again.
 *  Thread Starter [Bharath Gupta](https://wordpress.org/support/users/sribharath/)
 * (@sribharath)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2121842)
 * Yeah
 * `$query = new WP_Query( array( 'meta_key' => 'color', 'meta_value' => 'blue' ));`
 * This is cool but how do i add category filter there ?
 *  Moderator [Samuel Wood (Otto)](https://wordpress.org/support/users/otto42/)
 * (@otto42)
 * WordPress.org Admin
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2122064)
 *     ```
       $query = new WP_Query( array(
         'meta_key' => 'color',
         'meta_value' => 'blue',
         'category_name' => 'gallery',
        ) );
       ```
   
 *  Thread Starter [Bharath Gupta](https://wordpress.org/support/users/sribharath/)
 * (@sribharath)
 * [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2122065)
 * Thats great and here meta value changes ..Its not static ..
 * how do i say the query to look at the meta value ?

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Filtering Posts’ is closed to new replies.

## Tags

 * [filtering posts](https://wordpress.org/support/topic-tag/filtering-posts/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 3 participants
 * Last reply from: [Bharath Gupta](https://wordpress.org/support/users/sribharath/)
 * Last activity: [15 years ago](https://wordpress.org/support/topic/filtering-posts-1/#post-2122065)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
