• Resolved Peter Berger

    (@peterpolow)


    Hello Eliot,

    I’m trying to pass the value of a relationship field to an other shortcode, but it doesn’t work. I hope you can help me.

    I have a (ACF) relationship field for posts where I can select related events (cpt from the all-in-one event calendar plugin). The “return format” is set to “Post IDs”.

    I want to use it like this, but it doesn’t work:

    [pass field=related_events]
    [ai1ec post_id="{FIELD}"]
    [/pass]

    When I add one event to the field and use [field related_events], it returns the post id of the event, for example 1978. When I add more then one event, it returns 1978, 1979. That’s fine!

    But when I pass the field value like this, it returns (Array):

    [pass field=related_events]
    {FIELD}
    [/pass]

    I also tried to use the [pass array=related_events], but I don’t think that’s the solution, because the field doesn’t have different array keys (?). And I don’t know what you mean with “If the array is a series of values, use the index as key”.

    Do you know what I have to change to make it work?

    Thank you in advance!

    Peter

    https://wordpress.org/plugins/custom-content-shortcode/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Eliot Akira

    (@miyarakira)

    In the latest update (v3.2.8), I changed back the behavior for passing a field whose value is an array: it will no longer display (Array) but a comma-separated list. I’m not sure why I made that change — possibly because if the array was more than one level deep, it may have an issue with making a string out of it.

    To pass individual items of an array which is not in key-value pairs but only a series of values..

    [pass array=related_events]
    {0}, {1}, {2}
    [/pass]

    That’s what was meant by using the “index as key”. I clarified it in the documentation.

    Thread Starter Peter Berger

    (@peterpolow)

    Sorry for my late reply. I wanted to test it first, but I was busy with an other project.

    So I test it now and it works like a charm! 🙂 Thank you very much for your support, another nice update and all your time you’re spending on this.

    Stay motivated!

    Peter

    Plugin Author Eliot Akira

    (@miyarakira)

    Great, thank you for the confirming that it works.

    Stay motivated!

    I appreciate it! Knowing that sites are depending on the plugin, I feel responsible for keeping it running well. It’s satisfying to build something useful, so I’m hoping to grow this project more, branch out into a collection of plugins, provide commonly needed features, increase community engagement and “fun factor”.. So an ambitious dream is motivating me also. 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Pass relationship field to other shortcode’ is closed to new replies.