Custom Fields
Re-Envisioned
Support MB Views Views Shortcodes in Oxygen repeater

  • Creator
    Topic
  • #30497

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Author
    Replies
  • #30506
    Long Nguyen
    Moderator

    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

    #30507

    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

    #30510
    Long Nguyen
    Moderator

    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');
    ?>
    #30524

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.