2
Code
<?php
$files = $obj->field('upload');
foreach ($files as $file)
{
$file_url = get_attached_file($file['id']);
echo '<a href="' . $file["guid"] . '">' . $file["post_title"] . '</a>';
echo '<br>';
}
?>
Error message when not attached:
Warning: Invalid argument supplied for foreach() in /var/www/html/wp-content/plugins/pods/Components/Templates/Templates.php(500) : Eval()’d code on line 8
The variable
$obj
is an instance of which class? Post a little more code.– Rodrigo Rigotti
Check whether
$files
has some element, can use thecount()
;)– rray
This is the part of the code I call inside the pods template
– Rodrigo
<tr> <td> <? php $files = $obj->field('upload'); foreach ( $files as $file ) { $file_url = attach_ed_file($file['id']); echo '<a href="' . $file["guid"] . '">' . $file["post_title"] . '</a>'; echo '<br>'; } ? > </td> <td>{@object}</td> <td>{@aperture}</td> <td>{@valor_da_gru}</td> <td>{@fase}</td> </tr>
– Rodrigo
I don’t know much so I have a hard time explaining.
– Rodrigo
@Rodrigo, what the emtpy function does is to check if a variable is empty, literally - Empty
– Edilson