• Resolved jenjohn

    (@jenjohn)


    OK, maybe this has been asked and answered already, but I can’t find it with any of my search queries, and I’m somewhat new to wordpress.

    I would like to list out the names of the custom fields in a custom type, and possibly do this for all my custom types, to have a quick reference handy. Some of these custom types are from types that came in plugins, not necessarily types I created.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The query below will list out all the custom fields for the post type ‘parks’:

    $post_type = 'parks';
    
    $sql = "SELECT DISTINCT meta_key
    FROM $wpdb->postmeta pm, $wpdb->posts p
    WHERE p.post_type = '$post_type'
    AND p.ID = pm.post_id
    AND p.post_status = 'publish'
    ORDER BY meta_key ASC";
    
    $results = $wpdb->get_col($sql);
    //print_r('<pre>META_KEYS:');print_r($results);print_r('</pre>');
    foreach ( $results as $result ) {
       echo "<p>$result</p>";
    }
    Thread Starter jenjohn

    (@jenjohn)

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get field names of custom type’ is closed to new replies.