developer-blog-content
developer-blog-content copied to clipboard
Extending the Query Loop default fields
Discussed in https://github.com/WordPress/developer-blog-content/discussions/324
Originally posted by paaljoachim October 22, 2024 Currently the Query Loop will show the default fields of Title, Featured image, date and excerpt. It would be helpful to extend the Query Loop to show additional fields.
A use case. An artist has an album post. It uses the standard fields. Title = album name Featured image = album cover Excerpt = a description of the album Date = date when the album came out
He would like to add artists whom contributed to the album. He especially would like to add album tracks.
This means two additional fields: Contributed to album and tracks
As I see it one would need to define specific blocks that will be seen in the Album preview page where the Query loop would also show these specific blocks.
It would actually be very helpful to have two methods for this. Likely the regular Json file and code snippets. Code snippets would be an easy way to add a snippet directly to the web site without even having access to the files outside of WordPress. Having a Code snippet plugin one could just add the snippet turn it on and see the result. Go forth and back between the result and the snippet to easily adjust the code.
@paaljoachim This topic was approved. Would you be available to write this tutorial for the developer blog?
Hey @bph Birgit.
Yes. That I would like to do. I will need help though. I can probably ask questions in the core-dev-blog Slack channel. As this will be my first article.
That's awesome, @paaljoachim Thank you! I sent you an invitation for this repo so you can move the issue along in the Developer Blog Content Board
And here are three links for you. They should get you started.
Notes on creating and formatting a Google Doc #242 This issue also has a link to the Google Doc Template.
Yes, you can always ask questions in the core-dev-blog channel, or comment on this issue.
See also Slack discussion in #core-dev-blog
Thinking out loud. The first step seems to be creating a Custom Post Type. For that I would like to follow the most up to date tutorial on creating a CPT. I have for my various sites used the CPTUI plugin https://wordpress.org/plugins/custom-post-type-ui/
But I do wonder if WP core has a method I can follow instead that uses newer methods that can be easy to follow.
Second step is testing out the https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/extending-the-query-loop-block/ (I see that is has just been updated) Then looking at: https://developer.wordpress.org/news/2022/12/building-a-book-review-grid-with-a-query-loop-block-variation/ and