Viewing 2 replies - 1 through 2 (of 2 total)
  • I have the same problem, meta data seems to be ordered by date modified not meta_id like you would expect 🙁

    Had the same problem.
    Ended up putting together a function to select custom fields.

    General notes here:
    http://blog.tinkerworkshop.com/wordpress-get_post_custom-wrong-order/

    Function is:

    function get_post_custom_X($id){
    	global $wpdb;
        $querystr = "SELECT wposts.ID, wpostmeta.meta_ID, wpostmeta.meta_key, wpostmeta.meta_value ".
        			"FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta ".
        			"WHERE wposts.ID = wpostmeta.post_id AND wposts.ID = ".$id." ".
        			"ORDER BY wpostmeta.meta_id ASC";
    	$pageposts = $wpdb->get_results($querystr, OBJECT);
    	$return = array();
    	foreach($pageposts AS $key=>$val){
    		$return[$val->meta_key][] = $val->meta_value;
    	}
    	return $return;
    	//print '<!--'.print_r($return).'-->';
    }

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘get_post_meta, get_post_custom array indexing problems’ is closed to new replies.