Show latest posts on sidebar

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

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: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

Do you use the plugin Navigation or your own code?

I cannot reproduce the problem with the plugin Navigation.
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
rahuldottech
Ssr. Bludit
Posts: 27
Joined: Fri Sep 22, 2017 8:13 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: 3121
Joined: Sun Aug 09, 2015 5:01 pm
Location: Zurich
Has thanked: 54 times
Been thanked: 77 times
Contact:

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
Clickwork - Websites mit Bludit | Planet Bludit - Tipps und Snippets
rahuldottech
Ssr. Bludit
Posts: 27
Joined: Fri Sep 22, 2017 8:13 pm

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