• finnfin

    (@finnfin)


    Hi,
    I have a strange issue which is driving me crazy. I’m trying to link to a related post. This works fine

    [related field_name]
      [field link]
    [/related]

    But if I try to use

    [related field_name]
      <a href="[field url]">[field first_name]</a>
    [/related]

    It only shows link to current page. [field url] alone without the href tag works fine inside the related shortcode as well.

    If that’s not gonna work, my other question is how can I set the [field link] text to be an ACF field for example [field first_name], and not the title of a post?

    Thanks!

    • This topic was modified 4 years ago by finnfin.
Viewing 10 replies - 1 through 10 (of 10 total)
  • polarracing

    (@polarracing)

    The wordpress content filter hits in.

    Try this:

    [related field_name]
    [pass field=url,first_name]
      <a href="{URL}">{FIRST_NAME}</a>
    [/pass]
    [/related]
    Thread Starter finnfin

    (@finnfin)

    Thanks for the quick reply. That didn’t seem to quite work though. Neither URL or field value seems to have passed. I see {FIRST_NAME} as link text and link is pointing to ../%7BURL%7D

    polarracing

    (@polarracing)

    OK then the fields are not part of related
    This should work

    [pass field=url,first_name]
    [related field_name]
      <a href="{URL}">{FIRST_NAME}</a>
    [/related]
    [/pass]
    Thread Starter finnfin

    (@finnfin)

    They are a part of related, but I forgot to mention the related field is inside of a repeater, sorry about that. Could that somehow be causing the issue?

    That second suggestion gives the same result as first.

    Thanks for the help, I really appreciate it.

    polarracing

    (@polarracing)

    Post the result source code

    polarracing

    (@polarracing)

    Or try this:

    [related field_name]
    [link field=url][field first_name][/link]
    [/related]
    Thread Starter finnfin

    (@finnfin)

    That works! Thank you very much. Workaround for the href issue, but as long as it works! Was wondering there must be a way to use it like that, but didn’t know the [/url] syntax.
    Thanks again!

    Thread Starter finnfin

    (@finnfin)

    One more quick question. When using the [link] shortcode like this, is there a way to set the target attribute to be new tab?

    open=new

    Thread Starter finnfin

    (@finnfin)

    Perfect! Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘ACF Related url’ is closed to new replies.