Home » Filter custom fields list in schemas
Filter custom fields list in schemas

SiteSEO provides a way to get custom field using a hook.

Hook: seopress_get_custom_fields

Since: 1.0.0

Usage:

function siteseo_extended_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 SiteSEO, 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 '\_siteseo%%'
			ORDER BY meta_key
			LIMIT $limit" );

	return $cf_keys;
}
add_filter('siteseo_get_custom_fields', 'siteseo_extended_get_custom_fields');

Note: We suggest you use siteseo_extended_ as a prefix for every callback function, to keep things consistent and non-conflicting.

    Was this page helpful?
    Newsletter Subscription
    Subscribing you to the mailing list