I am using Kadence and wanted to add a view to the template loop for archive. The view only sees on CPT entry on the archive page and every post shows the same content.
I tried to move the view to take over the archive but had similar results.
How do I tell the view to show data from current loop item? I added the view within the query loop item but it doesn’t like being added multiple times to the page b
You can use the WordPress function get_the_ID() to get the post ID in the loop, and use the helper function rwmb_meta() to get the field value based on the post ID. Remember to use the view Type: Shortcode and add the shortcode to the loop. For example:
{% set post_id = mb.get_the_ID() %}
PostID: {{ post_id }}
Field value: {{ mb.rwmb_meta( 'my-field-id', '', post_id ) }}
Eh, not really working. Plus, I have relational fields going. Not even the post title works, let along a custom field. Still can't iterate over the posts in the main query loop.
If you create a custom query (loop) in the View, you can use the helper function rwmb_meta() or click on the field name in the Insert Fields tab to get the field value. See this screenshot https://monosnap.com/file/m6icy7DSacrLey0boxiUkUIFU7kJ4I
And please notice that the post_title is not a custom field created by Meta Box, it is a property of the Post object so you can just use post.post_title to get the post title.