Filter, Search and Sort WordPress Posts by Custom Field Value
To filter posts by a custom field in WordPress, the field has to become part of the query: "all events in Lisbon", "every staff profile without a last name", "properties priced from 200,000 to 300,000". In WOLF a custom field (post meta) works like any built-in column once it is added. You can filter by its value, search it from the tools panel, sort the table by it, and then bulk edit or export exactly the posts you found. A few rules about field types and missing values decide whether the results are right.
Make the custom field filterable
A custom field shows up in the Filters tab only after two steps:
- In the Meta Fields tab, add the meta key, give it a readable title and choose its type: string for text, number for values you want to compare or sort as numbers. Click Save meta fields.
- In the Settings tab, enable the new column and click Save all settings.
The second step is the one that gets skipped. Filters, quick search and Bulk Edit only offer custom fields whose column is active. How to find the real meta key of a field from a theme or plugin, and which type to give it, is covered in bulk editing custom fields.
Filter posts by a custom field value
The Filters tab gives each active custom field a filter that matches its type.
Text fields
A string field gets a text input with its title as the placeholder, and a behaviour drop-down:
| Behaviour | Finds posts where the field |
|---|---|
| LIKE | contains the text |
| EXACT (=) | is exactly the text |
| NOT EXACT (!=) | has a different value |
| NOT LIKE | does not contain the text |
| Empty | is empty, or the post does not have the field at all |
| NOT Empty | has any non-empty value |
Mind the difference between the negative behaviours and Empty. NOT EXACT (!=) and NOT LIKE only look at posts that have the field. A post that never got the field is not "different", it simply has no value, and only Empty finds it. To get "every post that is not in Lisbon, including the ones without a city", filter twice or fill in the missing values first.
Unlike the title and content filters, the custom field LIKE is a plain "contains", so dots, brackets and other symbols in codes are matched as they are.
Number, date and checkbox fields
- A number field gets a from and a to input. Fill both for a range. Fill only from for "at least". Fill only to for "up to", which starts at 0. Equal values find one exact number. Both inputs empty or 0 means no filter, so the value 0 itself cannot be searched this way.
- A number field with the calendar view gets date inputs instead. It expects dates stored as Unix timestamps, which is how WOLF saves them.
- A field with the checkbox view gets a Yes / No drop-down.
All filters combine with AND: a custom field filter together with a category, [post] status, By author and a Date Published range narrows the result step by step.
Quick search by a custom field
The quick search on the tools panel of the Posts Editor offers Title and ID by default. To look up posts by a code or a name stored in a custom field, such as a GTIN/EAN, an ISBN or a last name, add the field to it:
- Open the Settings tab and find Add fields to the quick search.
- Enter
meta_key:Titlepairs separated by commas, for example_gtin:GTIN,last_name:Last name. The part before the colon is the meta key, the part after it is the label in the drop-down. - Click Save all settings and reload the page.
The setting works only for text fields, so the fields must be of type string with an active column. Core text fields work too, for example post_name:Slug,post_content:Content. When you pick a custom field in the quick search drop-down, the behaviour list switches to that field's options, LIKE, EXACT (=) and the rest. A quick search clears the Filters tab and filters by that one field only, so run combined searches from the Filters tab. Developers can add options in code with the wpbe_quick_search_options filter, which receives the array of key => label pairs.
Sort posts by a custom field
Custom field columns are sortable: click the column header in the Posts Editor. To open the table sorted by a field every time, choose it under Default sort by and Default sort in the Settings tab. How the order comes out depends on the type you gave the field:
- number sorts numerically: 9, 20, 100.
- string sorts alphabetically, character by character: 100, 20, 9. Numbers saved as string therefore sort "wrong", so switch such fields to number. Values with units or thousands separators ("15 kg", "1,200") cannot sort as numbers at all.
Dates sort correctly in two formats only. Unix timestamps or Ymd numbers such as 20261012 sort correctly as number. Strings in year-month-day order such as 2026-10-12 08:30:00 sort correctly as string, because alphabetical order equals date order. Formats like 12/10/2026 sort by day, not by date. Do not switch a date string to number to "make it sortable". The column then shows only the year, and saving a cell would store that number in place of the date.
Posts disappear when you sort by the field
Sorting by a custom field asks WordPress for posts ordered by that meta key. WordPress can only order posts that have the key, so posts without it drop out of the table for as long as the sort is active. They come back when you sort by another column. This often happens with a field you just added that only a few posts have. To keep every post in the sorted table, give the missing ones a value:
- A new field that no post has yet: run a Bulk Edit over all posts with set new and
0for a number, or new and a default text for a string. - A string field that some posts have: filter it with Empty and set the default with new on that result only.
- A number field that some posts have: number filters have no Empty option. Switch the field to string in the Meta Fields tab for a moment, filter Empty, set
0, then switch it back to number.
Only fill in a default if a placeholder value means nothing wrong on the site, for example 0 for a sort order. A theme might print it.
Save the combination, then edit or export
A filter you will need again, such as "drafts in Events with an empty venue", can be stored with the Filters profiles button on the tools panel. Saving works while a filter is applied. Profiles are stored per user, so every editor keeps their own. The filtered set is also what the next steps work on:
- The Bulk Edit tab applies a change to all filtered posts unless some are selected with checkboxes.
- The Export tab writes the filtered posts with your active columns to CSV or XML.
If filtering or sorting by the custom field does not work
- The field is not in the Filters tab or the quick search: its column is not active in the Settings tab, or the post type has its own columns because Separate columns and meta for post types is on. Number fields cannot be used in the quick search; filter them in the Filters tab.
- The filter finds nothing: compare the stored value in a cell with what you typed. Fields from choice lists often store a key (
lisbon) rather than the label (Lisbon), and arrays are stored serialized; LIKE finds text inside them. - The sort order looks random: the field type does not match the data (see above).
- Clicking the header does not sort by the field at all: check the meta key for capital letters. The sort parameter is lowercased, so a key like
Last_Namecannot be matched for sorting. Filtering by it still works.
For a worked example on one kind of content, see bulk editing real estate listings and job listings. If a field still cannot be filtered or sorted, describe the meta key, its type in the Meta Fields tab and an example value on the WOLF support forum.