---
title: Filter custom fields list in schemas
url: "https://www.seopress.org/support/hooks/filter-custom-fields-list-in-schemas/"
lang: en-US
updated: 2022-08-15
hook_name: seopress_get_custom_fields
required_version: 3.7.4
---

# Filter custom fields list in schemas

- **Hook name:** `seopress_get_custom_fields`
- **Required version:** 3.7.4

```php
function sp_get_custom_fields($cf_keys) {
	global $wpdb;
	
	//By default, we limit the post meta (custom fields) items to 250 max
	//This will increase the number to 400
	$limit = (int) apply_filters( 'postmeta_form_limit', 400 ); //default: 250
	
	//This SQL query will request all your custom fields except the ones added by SEOPress, it means, hidden post meta starting by an underscore will also appear from the list
	$cf_keys = $wpdb->get_col( "
			SELECT meta_key
			FROM $wpdb->postmeta
			GROUP BY meta_key
			HAVING meta_key NOT LIKE '\_seopress%%'
			ORDER BY meta_key
			LIMIT $limit" );

	return $cf_keys;
}
add_filter('seopress_get_custom_fields', 'sp_get_custom_fields');
```

Source: [https://gist.github.com/wp-seopress/61731f81eb756e6b16bf489ada4d09a9](https://gist.github.com/wp-seopress/61731f81eb756e6b16bf489ada4d09a9)



