Show latest posts on sidebar

Post Reply
rahuldottech
Ssr. Bludit
Posts: 27
Joined: Fri Sep 22, 2017 8:13 pm

Sat Jan 12, 2019 7:52 am

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?
User avatar
Edi
Site Admin
Posts: 1544
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Sat Jan 12, 2019 2:33 pm

Do you use the plugin Navigation or your own code?

I cannot reproduce the problem with the plugin Navigation.
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
rahuldottech
Ssr. Bludit
Posts: 27
Joined: Fri Sep 22, 2017 8:13 pm

Sat Jan 12, 2019 7:42 pm

Hi Eli. This is not code from the plug-in, it is already present in the sidebar of the Striped theme.
User avatar
Edi
Site Admin
Posts: 1544
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Contact:

Mon Jan 14, 2019 11:26 am

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
Planet Bludit, Tipps, Snippets und nützliche Links. - Newsletter, Informationen zu Bludit (auf Deutsch).
rahuldottech
Ssr. Bludit
Posts: 27
Joined: Fri Sep 22, 2017 8:13 pm

Sat Jan 19, 2019 6:15 pm

Hey. I just ended up modifying the navigation plugin and using it. Thanks for your help :)
Post Reply