WordPress.org

Ready to get started?Download WordPress

Forums

Pods - Custom Content Types and Fields
[resolved] Can't display image field type with php (4 posts)

  1. George
    Member
    Posted 3 months ago #

    I created an image field type and it displays the link to the image while using the shortcode, but when i try displaying it with php it outputs "Array".

    This is the code i use to display the value:
    <?php $cover = get_post_meta( get_the_ID(), 'cover', true ); echo $cover; ?>
    I use the same code to display other fields and it works fine.
    Field Label: Cover
    Field name: cover

    https://wordpress.org/plugins/pods/

  2. Josh Pollock
    Member
    Plugin Author

    Posted 3 months ago #

    $cover is a field array. You can get the ID of the attachment with $cover['ID'] and pass that to any WordPress image function or use pods_image().

    For an example of how this works see:
    https://github.com/pods-framework/pods-code-library/blob/master/example/includes/media/pods_image/examples/get-post-meta.php

    For more info on pods_image() see:
    http://pods.io/docs/code/field-functions/pods-image/

  3. George
    Member
    Posted 3 months ago #

    Figured it out, thanks.

  4. Josh Pollock
    Member
    Plugin Author

    Posted 3 months ago #

    George-

    I'm glad to see you got this working. Please let me know if you need any help in the future using Pods.

    Take care,
    Josh

Reply

You must log in to post.

About this Plugin

About this Topic