Archived topic
Different content on sidebars based on the page / post / category
3 replies · Started by Yonatan on July 7, 2022
Hi.
I want to show different content on the same sidebar, based on the page or post or category.
For example:
On page A, on the left sidebar, I want to show a list of posts from the category "cars" + a contact form.
On page B, on the left sidebar, I want to show a list of posts from the category "houses" + a contact form.
How to I achieve this?
Thank you.
Hi Yonatan,
You can add a GenerateBlocks Query Loop Block in your left sidebar. You can use filter generateblocks_query_loop_args to filter which posts will appear depending on a page/post/category.
An example of how to use the filter to show related posts is this: https://community.generateblocks.com/t/use-gb-query-loop-for-related-post/688#:~:text=In%201.5.0%2Dbeta.2%2C%20you%E2%80%99ll%20be%20able%20to%20do%20this
Hope this clarifies!
Thank you.
Where to I paste this code?
Hi there,
You can use one of the methods introduced here to add PHP code:
https://docs.generatepress.com/article/adding-php/