0
votes

Hello I want to have multiple categories on one page (as a preview). Example:

Category 1 
POST1, POST2...

Category 2 
POST1, POST2... 

Category 3 
POST1, POST2...
...

There can be many categories, so I want to loop through them and then displaying posts depending on actual category.

My blog component look like this:

[blogPosts categoriesPreview]
pageNumber = "{{ page }}"
categoryFilter = "top-recipes"
postsPerPage = 4
noPostsMessage = "No posts found"
sortOrder = "published_at desc"
categoryPage = "recipes-category"
postPage = "recipes-detail"

Best way to solve this is pass category to "categoryFilter" in component, like this:

{% component 'categoriesPreview' categoryFilter= category.name %}

But it's not working... I have no idea how to solve this. Please help :)

1
you can check this ans: stackoverflow.com/questions/55347814/… it may help you how to pass it and make it work.Hardik Satasiya
THX, for your comment. Will try that this evening... Anyway, is there some other solutions to do this, without to change Blog plugin?UnafenýKonýk
no we are not changing blog plugin in any way with that solution. please try it if you ace any issue comment it, we will solve itHardik Satasiya
@HardikSatasiya When I was trying to do it like in the answer, I realize that every category has posts already in object :O So all I need to do is: {% set catPosts = category.posts %} that's all! But still I'm really thankful for your advice.UnafenýKonýk
ohk, I didn't look question that way my bad :)Hardik Satasiya

1 Answers

1
votes

For future generation (or just for future myself :)) To display all posts depends on category. Simple use [blogCategories] component. Every category has all blog posts already in object, so its not necessary to call another (post list) component with category filter passed to them.