Title: meta_key does not work, please help.
Last modified: August 22, 2016

---

# meta_key does not work, please help.

 *  [Wahtel](https://wordpress.org/support/users/wahtel/)
 * (@wahtel)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/meta_key-does-not-work-please-help/)
 * Hi, i’m trying to display post with meta_key => ‘deco_special_project’
    like 
   this:
 *     ```
       <div class="widget-content">
   
       		<?php
       		$args  = array(
       			'post_status'    => 'publish',
       			'meta_value'     => 1,
       			'posts_per_page' => 1,
       			'meta_key'       => 'deco_special_project',
       		);
       		$query = new WP_Query( $args );
       		// The Loop
       		while ( $query->have_posts() ) {
       		$query->the_post();
       		$post_id   = get_the_ID();
       		$thumb_url = wp_get_attachment_image_src( get_post_thumbnail_id( $post_id ), 'deco_post_300_200' ) [0];
       		?>
   
       		<article class="post-excerpt post-normal">
   
       			<a href="#">
   
       				<figure class="img-load">
       					<img src="<?php echo $thumb_url; ?>">
       				</figure>
   
       				<header>
   
       					<h4><?php the_title(); ?></h4>
   
       					<aside>
       						<time datetime="05.11.2014"><i class="de-icon-time"></i> 5 ноября</time>
       						<a href="#"><i class="de-icon-comment"></i> 10</a>
       						<span><i class="de-icon-views"></i> 3</span>
       					</aside>
   
       				</header>
   
       			</a>
   
       		</article>
   
       		<?php
       		}
       		wp_reset_query();
       		?>
   
       		<div class="blogroll-column blogroll-column-small">
       			<?php
       			$args = array(
       				'post_type'      => 'post',
       				'posts_per_page' => 5,
       				'post_status'    => 'publish',
       			);
   
       			$query = new WP_Query( $args );
       			// The Loop
       			while ($query->have_posts()) {
       				$query->the_post();
   
       				$post_id = get_the_ID();
       				?>
       			<article class="post-excerpt">
   
       				<a href="<?php echo get_permalink( $post_id ); ?>">
   
       					<header>
   
       						<h4><?php the_title(); ?></h4>
   
       						<aside>
       							<time datetime="05.11.2014"><i class="de-icon-time"></i> 5 ноября</time>
       							<a href="#"><i class="de-icon-comment"></i> 10</a>
       							<span><i class="de-icon-views"></i> 3</span>
       						</aside>
   
       					</header>
   
       				</a>
   
       			</article>
       			<?php
       			}
       			wp_reset_query();
       			?>
   
       		</div>
   
       		<article class="post-banner">
   
       			<a href="<?php echo get_permalink( get_the_ID() ); ?>">
   
       				<figure class="img-load">
       					<img src="/wp-content/themes/chai/assets/photo/thumb_google.jpg">
       				</figure>
   
       			</a>
   
       		</article>
   
       	</div>
       ```
   
 * It does not work, but if i will delete meta_key from args, it will show post,
   can somebody help me?

Viewing 1 replies (of 1 total)

 *  [efuller](https://wordpress.org/support/users/efuller/)
 * (@efuller)
 * [11 years, 6 months ago](https://wordpress.org/support/topic/meta_key-does-not-work-please-help/#post-5700640)
 * Try changing:
 *     ```
       $args  = array(
       	'post_status'    => 'publish',
       	'meta_value'     => 1,
       	'posts_per_page' => 1,
               'meta_key'       => 'deco_special_project',
       );
       ```
   
 * to
 *     ```
       $args  = array(
       	'post_status'    => 'publish',
       	'meta_value_num'     => 1,
       	'posts_per_page' => 1,
               'meta_key'       => 'deco_special_project',
       );
       ```
   
 * Reference: [http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters)

Viewing 1 replies (of 1 total)

The topic ‘meta_key does not work, please help.’ is closed to new replies.

 * In: [Installing WordPress](https://wordpress.org/support/forum/installation/)
 * 1 reply
 * 2 participants
 * Last reply from: [efuller](https://wordpress.org/support/users/efuller/)
 * Last activity: [11 years, 6 months ago](https://wordpress.org/support/topic/meta_key-does-not-work-please-help/#post-5700640)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
