Leave a Reply

3 comments

  1. The SQL query triggered by get_post_custom() is in update_meta_cache() and it looks like this:

    $wpdb->get_results( 
        $wpdb->prepare(
            "SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)",
            $meta_type
        ), 
        ARRAY_A 
    );
    

    So there is no ORDER BY given.

    Without ORDER BY the resulting order is almost unpredictable: it depends on the optimizer, used indexes and their order.

    The order the fields are saved doesn’t matter here.

    You can filter 'query' and add an ORDER BY clause to the query. See wp-includes/wp-db.php – wpdb::query() for details.

  2. You can call custom fields individually via the get_post_meta function:

    $meta = get_post_meta( $post_id, $key, $single ) //last argument is Boolean to return a single object or an array
    

    More info about it here. This way you can call your custom fields how ever you want.

  3. thanks to mr. pille for the push in the right direction. i created a new custom field with multiple values devided by “|” and use php explode to get my values:

    $cf = get_post_custom();
    if ($cf['ISSUU-multiID'][0]) {
      $ids = explode("|", $cf['ISSUU-multiID'][0]);
      foreach ($ids as $key => $id) {
        echo "<h4>" . $id . "</h4>n";
      }
    }
    

    …since i shall not edit any wp core files… thanks for the help…