Show latest posts on sidebar
Posted: Sat Jan 12, 2019 7:52 am
So... I have this code which shows me the latest posts on the sidebar:
However, it only seems to work on the home page. If I open a blog post or static page, then it only shows the current page. How can I fix this behaviour?
Code: Select all
echo '<nav id="nav">
<h2 class="plugin-label">Newest Content</h2>
<ul>';
foreach ($content as $page):
echo '<li><a href="#'.$page->slug().'">'.$page->title().'</a></li>';
endforeach;
echo '</ul></nav>';