• Resolved Inao

    (@inao)


    Thanks for your support. I have created a repeater upload field, I use with PDF files. but I can’t get back them. I only get back a number, but I did not figure out how to use it to retrieve the specific attachment.

    As documentation suggested i used:

    <?php foreach( get_cfc_meta(‘adjuntos’) as $key => $value ){
    ?> “/><?php }
    ?>

    I know it is wrong.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Georgian Cocora

    (@raster02)

    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!

    Plugin Author Georgian Cocora

    (@raster02)

    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: https://forecos.cl/plataforma-servidumbre-de-conservacion-reserva-costera-valdiviana/show-all-project/formulario-de-antecedentes/historial-de-solicitudes/?entry=329

    Plugin Author Georgian Cocora

    (@raster02)

    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!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Get Upload fields (Custom fields)’ is closed to new replies.