How to get keys of $posts array?
-
The $posts array (returned by wp_get_recent_posts) contains the following structure (as indicated by php print_r):
[0] => stdClass Object
(
[ID] => 128
[post_author] => 1
[post_date] => 2012-12-20 12:34:37
[post_date_gmt] => 2012-12-20 18:34:37
[post_content] => “Wasting no time, Vice President Joe Biden…[1] => stdClass Object
(
[ID] => 121
[post_author] => 1
[post_date] => 2012-08-27 11:06:02
[post_date_gmt] => 2012-08-27 17:06:02
[post_content] => Those of the population who are against…etc.
However, this
key($posts);
does not work (returns null value), whereas it should return the numeric key of the current pointer position in the array (e.g. 0, 1, etc.).How can I get the current $posts key from within a theme (Kippis in this case) without using key() or current()? Or–better–how can I get key() or current() to work for $posts?
- The topic ‘How to get keys of $posts array?’ is closed to new replies.