Hello @inao,
The number that you get is an attachment ID that points to the file. To get the URL, you need to use the wp_get_attachment_url() function over that number.
Let me know if this worked !
Regards.
Thread Starter
Inao
(@inao)
I’m so sorry my php knowledge is poor. I tried the following but it did not work.
<?php foreach(get_cfc_meta(‘adjuntos’) as $key => $value ){
?><?php wp_get_attachment_url(the_cfc_field(‘adjuntos’, ‘attached’)) ?><?php
}
?>
Thanks!
Hello @inao,
Put an echo before wp_get_attachment_url and it should display the URL of the file.
ex.
<?php foreach(get_cfc_meta(‘adjuntos’) as $key => $value ){
?><?php echo wp_get_attachment_url(the_cfc_field(‘adjuntos’, ‘attached’)) ?><?php
}
?>
Regards.
Thread Starter
Inao
(@inao)
I’m sorry it is only retrieving me the number :(.
here the complete peace of code:
`<?php
$args = array(
‘post_type’ => ‘correspondencia’,
‘meta_key’ => ‘codigo’,
‘meta_value’ => $resulthwe_meta[0]->meta_value,
‘order’ => ‘ASC’
);
$custom_query = new WP_Query( $args);
if ( $custom_query->have_posts() ) : while ( $custom_query->have_posts() ) : $custom_query->the_post();
?>
<?php $i = 0;?>
<?php if($i == 0){ echo “<div>”; }?>
<div class=”fullrowdiv”>
<div class=”rc_excol”><?php the_cfc_field(‘cartas’, ‘fecha’); ?></div>
<?php $i++;?>
<div class=”rc_excol2″><a href=”<?php the_cfc_field(‘cartas’, ‘archivo’);?>” target=”_blank”><?php the_title(); ?></a></div>
<?php $i++;?>
<div class=”rc_excol3″><?php the_cfc_field(‘cartas’, ‘remitente’); ?></div>
<?php $i++;?>
<div class=”rc_excol4″><?php foreach(get_cfc_meta(‘adjuntos’) as $key => $value ){
?><?php echo wp_get_attachment_url(the_cfc_field(‘adjuntos’, ‘attached’)); ?><?php
}
?>
</div>
</div>
<?php $i++;?>
<?php if($i == 4){ echo “</div>”; $i=0;}?>
<?php endwhile; ?>
<?php if($i < 4) echo ‘</div>’; ?>
<?php endif; wp_reset_query(); ?>
</div>`
This is an example page: http://forecos.cl/plataforma-servidumbre-de-conservacion-reserva-costera-valdiviana/show-all-project/formulario-de-antecedentes/historial-de-solicitudes/?entry=329
Hello @inao,
You figured this out ? I’m seeing that only the first post doesn’t have the correct link, maybe the attachment ID for it is wrong ?
If you need more help with this, please open a ticket on our website.
Regards.
Thread Starter
Inao
(@inao)
Thanks Georgian, not yet, Ok I will follow in your website!