I'm trying to get a list of all pages on a wordpress site and access their ID. I can get a list of pages using the get_pages() function. When I try to access any of the elements with their keys, it doesn't interpret.
For example, the following code wouldn't work:
$pages = get_pages();
foreach ($pages as $page) {
$ID = $page['ID'];
}
But, if I do this:
$pages = get_pages();
foreach($pages as $page) {
foreach ($page as $key => $value) {
echo("<p>$key</p>");
}
}
It clearly prints out ID as a valid key.
What am I doing wrong?
var_dumpor pages.$ID = $page->ID;is probably what you want