Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Guide for building atomic blocks for post meta values to be used within the Query Loop #30

Open
fabiankaegy opened this issue Apr 4, 2022 · 2 comments · May be fixed by #43
Open
Assignees
Labels
Good First Issue Good for newcomers Guide Help Wanted Extra attention is needed

Comments

@fabiankaegy
Copy link
Member

This is something that comes up again and again on client builds. Currently, the only way to show a meta value in the query loop is by building a custom block for it.

You can see some relevant discussions here:

@fabiankaegy fabiankaegy added Help Wanted Extra attention is needed Guide labels Apr 4, 2022
@fabiankaegy
Copy link
Member Author

As per a discussion in Slack I'm assigning this to @xavortm for now. Please let me know if you don't have the capacity to add a writeup and I will write one :)

@fabiankaegy
Copy link
Member Author

@xavortm Sorry for not adding more information about what I was thinking here initially. I'll try to outline what I had in mind below.

The main question I keep seeing is how we can leverage the core query loop for custom post types that have custom meta values. An example of this would be a Books custom post type that has custom meta values like price, isdn_number, number_of_pages, etc.

As a user, I now want to be able to build a query loop to display all the different books. But I want to make sure the Price and number of pages are always shown on each item.

You can look at all the different post- blocks in Gutenberg core for how they do it. But essentially what you have done in your PR (#43) for the first example already is most of the way there. It reads the postId from the context which is either set by the current post/page the block gets inserted on. Or inside of the core/post-template that value gets set to the ID of the current post in the loop.

So my goal for the guide would be to combine the second example of your PR with the first one to showcase how you can display actual post meta values in the query loop like in the example of the price/number of pages for the books.

@fabiankaegy fabiankaegy added the Good First Issue Good for newcomers label May 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue Good for newcomers Guide Help Wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants