• Resolved Alex

    (@amartignier)


    Hi,

    I’m using pods with the WordPress Theme Avada to create a custom pod named “Team Member” (team_member). In this pod I’ve created 3 fields : role(text), citation(text) and an photo_profil (file/image/video).

    In my wordpress theme, I can create post card layout that can iterate through all my “Team Member” entries. With this method, I can easily pull out text fields by adding a custom field (with my theme) and reference the name of the field.

    But I don’t know how to pull out data from a file/image/video field. If I use a php function, I’ve seen that the return type is an Array and I’ve managed to see the content. For ex:

    ID = 357
    post_author = 1
    post_date = 2023-10-20 10:58:35
    post_date_gmt = 2023-10-20 08:58:35
    post_content =
    post_title = celine
    post_excerpt =
    post_status = inherit
    comment_status = closed
    ping_status = closed
    post_password =
    post_name = celine
    to_ping =
    pinged =
    post_modified = 2023-10-20 11:00:19
    post_modified_gmt = 2023-10-20 09:00:19
    post_content_filtered =
    post_parent = 358
    guid = https://dev.powerofwe.ch/wp-content/uploads/2023/10/celine.webp
    menu_order = 0
    post_type = attachment
    post_mime_type = image/webp
    comment_count = 0
    pod_item_id = 357

    My field name is photo_profil. I tried differents ways to get the url of the image, but without success. For ex:

    photo_profil.guid
    or
    photo_profil._guid
    or
    @photo_profil.guid
    or
    photo_profil['guid']
    ...
    ..
    .

    Could you help me to return data from this file/image/video array?

    Thanks a lot!

    Alex

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @amartignier

    When referencing to metadata Avada probably uses get_post_meta() to fetch the data.

    If you can use shortcodes then this will probably be easiest: [pods field="FIELDNAME"].

    Otherwise you might try the Pods setting page and enable get metadata control, however, this isn’t preferable since it could slow down your site.

    GUID is only for internal usage so please never use this.

    Cheers, Jory

    Thread Starter Alex

    (@amartignier)

    Hi @keraweb,

    I tried your method and it works like a charm! Thanks

    But I wanted to use the options of an image element from Avada, so I made more tests and succeeded. What I did is that I created an image element, change the source to “shortcode” and create a shortcode with the following code :

    function getTeamAvatar(){
        global $post;    
        return wp_get_attachment_image(get_post_meta($post->ID)['photo_profil'][0],'full');
    }

    Maybe what I did it’s a little overwhelming?and there’s certainly a better way to achieve that, but it works so now I can use the options of the Image Element.

    Thanks again for your quick answer and your solution,

    Regards,

    Alex

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hi @amartignier

    That is actually a solid solution, didn’t know this would work in Avada, I’m not really familiar with that theme. Good job!

    Cheers, Jory

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Return data from an image file in custom field’ is closed to new replies.