Title: Custom post meta
Last modified: August 21, 2016

---

# Custom post meta

 *  [Piotr Po](https://wordpress.org/support/users/potreb/)
 * (@potreb)
 * [12 years ago](https://wordpress.org/support/topic/custom-post-meta-1/)
 * Hi
    I need help. I would like to retrieve the posts by meta query and sort them
   by value, no matter whether the meta post exists or not.
 *     ```
       $args=array(
       			'posts_per_page' => -1,
       			'meta_key' => 'mymeta',
       			'meta_type' => 'NUMERIC',
       			'orderby' => 'meta_value',
       			'order' => 'ASC',
       			'meta_query' => array(
       				'relation' => 'OR',
       				array(
       					'key' => 'mymeta',
       					'compare' => 'NOT EXISTS'
       				)
       			)
       		);
       		$query = new WP_Query($args);
       ```
   
 * If there is no entry in postmeta then does not show any entries

The topic ‘Custom post meta’ is closed to new replies.

 * 0 replies
 * 1 participant
 * Last reply from: [Piotr Po](https://wordpress.org/support/users/potreb/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/custom-post-meta-1/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
