简体   繁体   中英

Wordpress - Get User's image ID from Pods field

I am currently working with the Pods plugin.

I extended the user pod and I added a corporate image field.

On the administration everything is fine, I can change the image of each user.

在此处输入图片说明 AND :

在此处输入图片说明

My problem is that I can not display this image on a front office page..

If i do this : var_dump($pod->field('image_societe')); It return false, while the field name is correct, and for plain text fields, it works.

But i can do this :

var_dump($pod->fields('image_societe'));

This will return me full of information, but I do not have access to the id of the image, it is not present in the information.

I would like to finally be able to do this:

the_attachment_link( 11923 );

Where 11923 is the image's ID.

To be dynamic according to the user, the documentation says that it must be done like this:

the_attachment_link($pod->field('image_societe.ID'));

But as pods return me false, it does not work.

Does someone have an idea ?

Thank you !

Usually you can get the image url by querying $pod->field('image_societe.guid') . Eg :

$items = pods('your_pod', array("limit" => -1));
while($items->fetch()) {
    echo $items->field('image_societe.guid');
}

If $pod->field('image_societe'); doesn't return anything, then something might be wrong with your pod query, or caching kicking in. So more code would be needed to review this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM