• Resolved Nam_n

    (@nameez)


    Hi,

    I have a image custom field defiled in a custom post type called projects, can i know how to do the shortcode to loop through the posts and show images for each entry please.

    I tried this:

    [loop type=projects]
    [attached]
    <img scr="[field image=wpcf-image-1]">
    [/attached]
    [field excerpt]
    [/loop]

    It doesn’t show the image, but prints the path to it.

    Please advice.

    https://www.ads-software.com/plugins/custom-content-shortcode/

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

    (@miyarakira)

    Hello,

    This is because [attached] is for attachments, not image fields.

    To display an image field for each post:

    [loop type=projects]
      [field image=wpcf-image-1]
      [field excerpt]
    [/loop]

    For details, please see the documentation under Main Features -> Content -> Parameters: Image Field.

    Thread Starter Nam_n

    (@nameez)

    Hi,

    Thanks for the reply.

    I tried that but it doesn’t return anything except for the excerpt, when i add attched shortcode it prints the path to image..

    any ideas?

    Thanks

    Thread Starter Nam_n

    (@nameez)

    This is how the fields look in content overview page:

    https://www.dropbox.com/s/56hsa7k9poye8qr/Screenshot%202015-08-09%2013.47.42.png?dl=0

    Thanks

    Plugin Author Eliot Akira

    (@miyarakira)

    Could you tell me what kind of field value it contains?

    [field wpcf-image-1]

    I believe that should display a number, the image’s ID.

    You can also try the following:

    [loop type=projects]
      [attached]
        <img src="[field url]">
      [/attached]
      ...
    [/loop]

    But in that case, it will display all attachments of the post – not only what’s inside the image field.

    Thread Starter Nam_n

    (@nameez)

    Sorry this is the first time i’m trying to use custom posts, custom post (projects) is made from the plugin called Types (https://www.ads-software.com/plugins/types/) and i have added a custom field called image to it for the user to upload the image for the project.

    To answer your questions:

    [field wpcf-image-1]

    should contain the path to the image uploaded.

    And

    [loop type=projects]
      [attached]
        <img src="[field url]">
      [/attached]
      ...
    [/loop]

    Doesn’t seems to be returning anything.

    I should say your plugin works brilliantly with loop and other data, this is the only issue i have.

    Thanks

    Plugin Author Eliot Akira

    (@miyarakira)

    [field wpcf-image-1] should contain the path to the image uploaded.

    In that case, how about this?

    [loop type=projects]
      <img src="[field wpcf-image-1]">
      [field excerpt]
    [/loop]
    Thread Starter Nam_n

    (@nameez)

    Brilliant! thanks.
    Great plugin and great support, 5 star rated.

    Plugin Author Eliot Akira

    (@miyarakira)

    Thanks, I’m glad that worked. ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Attachment image problem!’ is closed to new replies.