Archived topic
Posts in blog sidebar.
16 replies · Started by Francesco on December 1, 2021
Hi Guy,
thanks for the work you do.
I'd like the blog sidebar to only show articles of the same categories as the article being displayed. I searched for hours but couldn't get anything out of it.
What I'm doing wrong?
Many thanks.
Francesco
Hi there,
WordPress doesn't have a widget to display related posts.
Are you just wanting the post title with link to be shown ?
Hi David,
look at the screenshot here: https://www.dropbox.com/s/79q267xrl73s7fm/Schermata%202021-12-01%20alle%2012.19.45.png?dl=0
The main article has categories "project" and "belarus". I would like to show in the sidebar just article with "project" and "belarus" categories. And that's not a problem, using WP showpost.
But.
If the main article has category "ukraine", I would like to show in the side bar just article with "ukraine" categoriy.
That's actually my problem.
Many thanks in advance
Francesco
The best method is to create a dynamic shortcode for displaying a WP Show Posts lists with the current category.
Elving provides the snippet to create that shortcode here:
Hi David,
many thanks. Ok, I've added the code in functions.php, inserted the new shortcode in the side bar, but I't doesn't work as aspected. Check here: https://www.genocideagainstroma.joro.xyz/ignorierter-volkermord-roma-in-belarus-1941-1944/
What I'm doing wrong?
Many thanks,
Francesco
What setting have you in your WP Show Posts list ? Can you remove any taxonomies
This is what I actually have: https://www.dropbox.com/s/82061rsco80lfph/Schermata%202021-12-01%20alle%2015.19.04.png?dl=0
In the sidenbar widget did you change it to use the Shortcode that Elvin provided in that topic ?
Yessir!
Hi there,
We may have to modify the shortcode a bit here.
Do you have any specific conditions for the related posts on the sidebar?
Example: Do you want to display posts from ALL of the categories the post has? Or perhaps display posts from some sort of a primary category?
Hi Elvin,
many thanks for your answer.
So, we have 3 projects (3 TAGs).
1) Tag1 - "Belarus
2) Tag2 - "Ukraine
3) Tag3 - "Transnistrien".
I would like that, if I read an article tagged "Belarus", the column on the right would show the other articles tagged "Belarus". Likewise for the tags "Ukraine" and "Transnistrien".
I was wondering, is it not possible to create 3 different templates for blog articles to get around this problem?
Many thanks in advance.
Francesco
Are there posts that have more than the one tag ? eg. in Tag 1 and Tag 2 ?
No, I would like to use the Tag just for the related posts on the sidebar.
For everything else I will use the categories.
As there are only 3 you could use a Block Element:
https://docs.generatepress.com/article/block-element-overview/
Which tehre are two options:
1. Set the Element Type to Right Sidebar.
This method relies on you building the entire sidebar in the block editor, so please note that not all classic widgets are supported.
OR
2. Set the Element Type to Hook, and set the Hook to before_right_sidebar_content
This will hook in before the right sidebar, so the content will be above it but it means you can still add stuff to normal widget area.
Then its a case of adding the relevant WPSP Shortcode to the Block Element Content. And setting your Display Rules to the Post Tag
Then repeat the above for each Tag.