Views Shortcodes in Oxygen repeater
- This topic has 7 replies, 3 voices, and was last updated 3 years, 4 months ago by
Yan Kiara.
-
AuthorPosts
-
August 30, 2021 at 3:20 PM #30497
[email protected]
ParticipantHi,
I´ve set repeater query to post_type and I´m trying to get custom field values via shortcodes I´m succesfully using on single post page template of the same post_type, but values do not appear except for date shortcode which does not return post value but current date.
Any thoughts? Is it me, or it is not possible to use shortcodes for this purpose?
ThanksAugust 30, 2021 at 10:24 PM #30506Long Nguyen
ModeratorHi,
If you do not pass the third argument to the helper function
rwmb_meta()
, it will take the current post ID (current query object ID) which means the ID of the post which has the repeater. It's not the IDs of the post in the list (repeater). Please read more here https://docs.metabox.io/rwmb-meta/#argumentsI think you can create a custom query to get posts by arguments and custom field values. Then put only the View shortcode to the Oxygen Builder. Follow on this documentation
https://docs.metabox.io/extensions/mb-views/#custom-queryAugust 31, 2021 at 1:31 AM #30507[email protected]
ParticipantThank you for your answer. I'm not that technical, but I'm trying to get through it. It is very important for my current and future projects. Now I see what is the problem. I need to tell rwmb helper function correct post id. I need to pass the correct third argument, as you suggest. I did some experiments with the repeater. I'm able to get correct post ID for each post within loop by using Oxygen dynamic field (in my case 187). But when I try to use this php code inside repeater
<?php echo 'The current post ID is: '.get_the_ID(); ?>
it returns ID of the "parent" post (in my case 189).
Tried also this code. Still returns "parents'" ID 189
<?php $examplePost = get_post(); echo $examplePost->ID; // Display the post's ID ?>
I also tried this hoping I will get the right custom value and know I'm on the right path, but I just got internal server error.
<?php rwmb_the_value ('cf-misto-konani',,$post_id = '187'); ?>
I hope I make myself clear.
thanksAugust 31, 2021 at 8:47 AM #30510Long Nguyen
ModeratorHi,
If you do not use the second argument, you need to leave it blank by using single quotes like this.
<?php rwmb_the_value ('cf-misto-konani', '', $post_id = '187'); ?>
September 1, 2021 at 12:39 AM #30524[email protected]
ParticipantImportant finding. rwmb helpers (via codeblock) work with repeaters, oxygen just does not show the data in the backend. Views shortcodes still not solved. My shortcodes are pretty simple.
{% set field = attribute( post, 'cf-misto-konani' ) %}
{{ field.name }}
Do you occasionally know how to tune it up so it works within a repeater too? I'm still diggin, but any advice would be appreciated.
thanksDecember 2, 2021 at 1:00 AM #32337Yan Kiara
ParticipantHi all,
Any update on this issue?I have the same problem, view shortcodes don't work in Oxygen repeater but rmwb_get_value is OK :
- post.title and post.date return the title and date of the page showing the repeater instead of the title/date of repeater item.
-
other date fields return current date.
Thanks
December 2, 2021 at 9:42 AM #32345Long Nguyen
ModeratorHi,
Using the View shortcode in the Oxygen repeater might not work because you are inserting variables from the main query. Please read more on the documentation https://docs.metabox.io/extensions/mb-views/#main-query
If you want to get the field value, please use the helper function
rwmb_meta()
, refer to this topic https://support.metabox.io/topic/error-using-cloneable-text-field/December 2, 2021 at 4:21 PM #32356Yan Kiara
ParticipantOK, I understand now, thanks for your fast answer 🙂
So, it means that inserted fields don't use rwmb functions to fetch field values???
It's a shame because this way they could work in all queries. -
AuthorPosts
- You must be logged in to reply to this topic.