If I insert multiple custom fields to my article, they get sorted in “I don’t know what” way. So when I insert some multiple fields in an article and call those via
$cf = get_post_custom();
foreach ($cf['ISSUU-configID'] as $key => $value) {
echo "<h4>" . $cf['ISSUU-configID'][$key] . "</h4>n";
}
their order is mixed up and neither logically ordered nor in the way I inserted them. Seems weird to me.
To make it a little clearer:
I insert these numbers, each one in an own custom field (in specifically that order):
12345, 23456, 34567, 45678
And the output will be something like (in fact this is always different):
45678, 23456, 12345, 34567
The SQL query triggered by
get_post_custom()
is inupdate_meta_cache()
and it looks like this: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 anORDER BY
clause to the query. Seewp-includes/wp-db.php
âwpdb::query()
for details.You can call custom fields individually via the
get_post_meta
function:More info about it here. This way you can call your custom fields how ever you want.
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:
…since i shall not edit any wp core files… thanks for the help…