• Resolved aurorasentinel1

    (@aurorasentinel1)


    I had been using code below to pull an image and two ACF fields. All three were linked in the . Now the link doesn’t work. Been trying everything but can’t get it to roll. Can anyone help?

    <h5>[loop type="post" id="311" count="1"]<a href="[content field='url']"> [content field="image"] [content field="employee-name"], <br/>[content field="employee-title"]</a>[/loop]</h5>

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

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

    (@miyarakira)

    1) Are you using this code inside the current post’s content (in text editor), or loading it from another post using shortcode or PHP?

    2) It sounds like the specific issue is that the URL inside the link doesn’t point correctly. Is it linking to the current post instead of each post in the loop? Or is the URL empty?

    3) It could be related to using “quotes”. Your code could be written without quotes, like this:

    <h5>[loop type=post id=311 count=1]<a href="[field url]"> [field image] [field employee-name], <br/>[field employee-title]</a>[/loop]</h5>

    Does that make any difference?

    Thread Starter aurorasentinel1

    (@aurorasentinel1)

    1. I’m not inside the current post content. I use the Pagelines DMS framework. It’s in a drag and drop text box. The old shortcake was working fine before all of the updates started.
    2. Hovering over the link shows it is linking to the current post, not the correct post id.
    3.Quotes made no difference.

    I tried using the [field image-link] and that yielded the correct results. So it is picking up the correct id. Those other fields are ACF so there is no alternative like title-link.

    Thread Starter aurorasentinel1

    (@aurorasentinel1)

    So I tried this:
    <h5>[loop type=post id=339 count=1]<a href=[content field=url]>[content field=image] [content field=employee-name], <br/>[content field=employee-title]</a>[/loop]</h5>

    and I get a 404 error with this url: http://leapmediaserv.staging.wpengine.com/people/%5Bcontent

    I see something in your documentation about an escape parameter. Does that come into play here?

    Thread Starter aurorasentinel1

    (@aurorasentinel1)

    And if I drop the code from above into the post content it works! But I need to drop it into a text box. Is there a solution for that?

    Plugin Author Eliot Akira

    (@miyarakira)

    Hello,

    I believe this is due to the change in WP 4.2.3, that shortcodes inside HTML attributes are removed. To get around this, I added a new shortcode [link] to create a link from a field value. By default it will link to the current post in the loop.

    <h5>[loop type=post id=311][link][field image] [field employee-name], <br/>[field employee-title][/link][/loop]</h5>

    For details, please see the documentation under Main Features -> Field -> Link to Field Value.

    Thread Starter aurorasentinel1

    (@aurorasentinel1)

    Perfect! Thanks so much.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Trouble with old shortcode’ is closed to new replies.