Tuesday, December 6, 2011

Get user added custom fields in WordPress

A short code to get all user added custom fields in WordPress:

<?php
$custom_fields = $wpdb->get_col("SELECT meta_key FROM $wpdb->postmeta GROUP BY meta_key HAVING meta_key NOT LIKE '\_%' ORDER BY meta_key");
natcasesort($custom_fields);
?>

No comments:

Post a Comment