Support Forum
Hi,
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?
Thanks
Hi,
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/#arguments
I 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-query
Thank 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.
thanks
Hi,
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');
?>
Important 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.
thanks
Hi 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 :
other date fields return current date.
Thanks
Hi,
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/
OK, 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.