Page 1 of 1

Show latest posts on sidebar

Posted: Sat Jan 12, 2019 7:52 am
by rahuldottech
So... I have this code which shows me the latest posts on the sidebar:

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>';
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?

Re: Show latest posts on sidebar

Posted: Sat Jan 12, 2019 2:33 pm
by Edi
Do you use the plugin Navigation or your own code?

I cannot reproduce the problem with the plugin Navigation.

Re: Show latest posts on sidebar

Posted: Sat Jan 12, 2019 7:42 pm
by rahuldottech
Hi Eli. This is not code from the plug-in, it is already present in the sidebar of the Striped theme.

Re: Show latest posts on sidebar

Posted: Mon Jan 14, 2019 11:26 am
by Edi
rahuldottech wrote: Sat Jan 12, 2019 7:42 pm This is not code from the plug-in, it is already present in the sidebar of the Striped theme.
Sorry, you are right.

But you can use the code of the plugin or a part of it (from line 49):

https://github.com/bludit/bludit/blob/m ... plugin.php

Re: Show latest posts on sidebar

Posted: Sat Jan 19, 2019 6:15 pm
by rahuldottech
Hey. I just ended up modifying the navigation plugin and using it. Thanks for your help :)