# Finding posts by their fields: ugly_find()

> No meta_query. You say what the fields must be.

Source: https://uglydev.com/docs/php-api/finding-posts-by-their-fields-ugly-find/
Updated: 22 November 2026

```php
$q = ugly_find( 'recipe', array(
	'difficulty' => 'easy',                    // equal to
	'minutes'    => '< 30',                    // < <= > >= !=
	'cuisine'    => array( 'italian', 'french' ), // any of these
	'vegan'      => true,                      // yes (false: no)
	'note'       => '~pasta',                  // contains
	'price'      => 'between 5 and 10',
	'author'     => $author_id,                // a relation that points at this post
), array( 'order' => 'minutes asc', 'limit' => 12 ) );

while ( $q->have_posts() ) {
	$q->the_post();
	// the loop
}
wp_reset_postdata();
```

It gives a normal `WP_Query`, so the loop is the one you know.

## What a value can be

| Value | Meaning |
| --- | --- |
| `'easy'`, `12` | Equal to |
| `'< 30'`, `'<= 30'`, `'> 5'`, `'>= 5'`, `'!= x'` | A comparison. Numbers are compared as numbers |
| `'between 5 and 10'` | Between two values, included |
| `'~text'` | Contains |
| `'empty'`, `'filled'` | Has nothing in it, or has something |
| `array( 'a', 'b' )` | Any of them |
| `true`, `false` | Yes or no |
| A post | A relation that points at that post |

## Options

| Option | What it does |
| --- | --- |
| `order` | `'minutes desc'`, `'title'`, `'date'`, `'random'` |
| `limit` | How many (default: WordPress' own) |
| `page` | Which page of results |
| `status` | The post status |
| `search` | A word to search for |
| `published` | When WordPress says it was published: `2026`, `'this year'`, `'this month'`, `'last 30 days'`, `'after 2026-05-20'`, `'between 2026-01-01 and 2026-03-31'` |

> **Tip:** dates of a date field are written `Y-m-d`, and compared with `between`, `<` and `>`.

> **Note:** a name that is not a field of that content type is reported in the debug log and left out. Posts that have no value in the field used to sort are not in the result.

> **The case for it:** [Stop writing meta_query](https://uglydev.com/blog/stop-writing-meta-query/) shows the same question in 26 lines and in five.
