I'm trying generate all my page links from my theme's function.php file. Right now what I have works, but it only gets the first page. I think this may be due to the fact it's not in a loop, but I'm not that familiar with doing this in the functions file as I normally generate my page links using wp_list_pages() in my theme file.
Here is the block of code I'm currently using:
function sitenav() {
$pages = get_pages();
foreach ($pages as $pagg) {
$option = '<li>';
$option .= '<a href="' . get_page_link($pagg->ID) . '">';
$option .= $pagg -> post_title;
$option .= '</a></li><li>:</li>';
return $option;
}
}
And then, I'm putting this function in a variable string, along with other HTML I need in the header area of my theme. And finally, I'm adding the action into a hook and echoing the full output.
Any suggestions on what I need to change/fix/add? Thanks!