get_post_meta, get_post_custom array indexing problems
-
Hi,
I’m experiencing some very weird array indexing problems for get_post_meta and get_post_custom.
In short, I want to have a post where I can enter multiple custom fields of the same type(name)and then extract the value of each and display them on a page in the order they were entered (in my case, the homepage).
I should also mention I am doing this outside of the Loop.
Instead of receiving an array that contains the custom field values in the same order I entered them in the admin area, the entries are mixed.
I tried this:
<?php $custom_fields = get_post_custom(244); $my_custom_field = $custom_fields['field_title_here']; foreach ( $my_custom_field as $key => $value ) echo $key . " => " . $value . "<br />"; ?>
and this
<?php $my_custom_field2 = get_post_meta(244,'field_title_here',false); foreach ( $my_custom_field2 as $key => $value ) echo $key . " => " . $value . "<br />"; ?>
Example output:
0 => Title 3
1 => Title 4
2 => Title 1
3 => Title 2The order I entered them in the admin area is ascending:
Title 1
Title 2
Title 3
Title 4Does anyone know what’s happening?
- The topic ‘get_post_meta, get_post_custom array indexing problems’ is closed to new replies.