• Resolved junkes

    (@junkes)


    Hey,

    I don’t even know how to begin because I feel like this could have so many ways to look at it. I will layout the base and then go to my questions. The thing is I have a CPT made with pods called CD with a field called Youtube, for example, to display the link to listen to that CD on Youtube. And I have a CPT made with Pods called Song related to that CD cpt by a, well, CD field. This is a Multiple Selection related field because a Song can be released in multiple CDs through the years.

    The problem is, I’m using Pods autotemplate to display the single pages for those Songs and I just want to use 1 of those Youtube links. I know I could use a pods shortcode to “limit=1” and get that field, but I want it inside an “href” markup, like Youtube and I get an error when doing it, it doesn’t work (also the second ” mark after the href stays in red in Pods template, meaning there’s something wrong, right?).

    Am I doing something wrong with that href=”[pods]” or that’s really not possible? Is there another way to do something like that?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @junkes

    This is a bit difficult since you don’t know which YouTube link will be shown if you just take the first one.

    I would advice to also add a YouTube field to the song Pod so you can easily manage which video will be shown on single song pages.

    If you really need to use the shortcode you need to set a constant to allow this: https://docs.pods.io/displaying-pods/pods-templates/using-shortcodes-in-pods-templates/

    Cheers, Jory

    Thread Starter junkes

    (@junkes)

    Actually, I don’t mind to get the first one because it’s getting a link to a CD that contains that song, so it would be ok, even preferable.

    I did everything about “Using Shortcodes in Pods Templates” and I use them a lot. My problem here is that it seems I can’t use them inside an href=”[pods]”, is that so? And if it is, would there be another way to do that?

    I thought about using a function to limit the outcome of {@CDs} to just one (preferable the first one ordered by a tax field called year), like {@CDs,my_function}, would that be possible?

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @junkes

    I recall reading something about shortcodes within attributes a while ago and no, I believe this isn’t supported by WordPress.

    In any case, using a custom helper function to output what you want correctly sounds like your best option to me! The first parameter would be the value and if there are multiple you can just get the first value of the array.

    Cheers, Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Limiting a Multiple Relationship Field to one output’ is closed to new replies.