WordPress.org

Ready to get started?Download WordPress

Forums

Advanced Custom Fields
Retuning the ID of the image instead of the url (3 posts)

  1. mrbrand
    Member
    Posted 2 years ago #

    I create a new custom field,
    type: image
    return value: image url,

    I post new entry and add image with add button

    Problem: the custome field gets the image attachment ID, not URL

    http://wordpress.org/extend/plugins/advanced-custom-fields/

  2. shel.80
    Member
    Posted 2 years ago #

    Hi mrbrand. I got stuck on this just now and found the answer:

    Let's say your field is named additional_image, then you'd use this code in your template:

    <img src="<?php the_field('additional_image'); ?>" alt="blah blah blah" />

    That would generate the url of the image and thus show up.

    More details here:

    http://www.advancedcustomfields.com/docs/field-types/image/

    Hope that helps!

  3. shel.80
    Member
    Posted 2 years ago #

    Just to add, even though you have selected image url as return value the custom field with still produce the attachment id number as the value (which is what puzzled me at first), but the code behind "the_field" function will allow it to get the url information.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic