WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top
<?php $fields = get_post_custom($ID); ?>

This will fetch the custom fields ($key => $value) for $ID in to the array $fields.

I want ALL the fields (both custom & standard WP fields) associated with the $ID in one array $fields_all. How to do this in a simpler way?....is there a single function available in WP?

share|improve this question

migrated from stackoverflow.com Aug 1 '11 at 5:03

This question came from our site for professional and enthusiast programmers.

there is no single function you can use but you can create your own something like:

function get_all_post_fields($post_id){
    $p['standard'] = get_post($post_id, ARRAY_A);
    $p['meta'] = get_post_custom($post_id);
    return $p;

then once you have this in your functions.php file you can use it:

$fields_all = get_all_post_fields($ID);


If you have just the title then i have a simple function i use a lot to get the post id by the title:

function get_post_ID_by_title($page_title) {
    global $wpdb;
        $post_id = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_title = %s AND post_type='post'", $page_title ));
        if ( $post_id )
            return post_id;
    return false;

usage: $post_id = get_post_ID_by_title("this is my title");

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.