Home Forums ACF PRO Probleme File download shortcode


Probleme File download shortcode

  • I have to make a shortcode for an item list under wordpress and the acf plugin (date, text + pdf file to download). I can display the date and text, but I can’t get the pdf download to work. I looked at the ACF doc with “Basic display (ID)” but I don’t see my error. Can you help me ?

    function orders_day($atts)
        $orders = get_field('ordres_du_jours', 'option');
        if ($orders){
            foreach ($orders as $order):
                $url_orders = wp_get_attachment_url($orders);  
                echo '<div class="info-adminis">';
                    echo '<h2>' . $order ['date_ordre_jour'] . '</h2>';
                    echo '<p>'. $order ['texte_de_presentation_de_lordre_du_jour'] .'</p>';
                    //MY PROBLEM HERE
                    echo '<a href="'. esc_html($url_orders) .'" >Télécharger</a>';
                echo '</div>';
                echo '<hr class="separator-adminis">';
        $short_list = ob_get_clean();;
        return $short_list;
    add_shortcode('ordre_jour', 'orders_day');
  • You need to supply the attachment ID in wp_get_attachment_url() and you are supplying the and array

    this $url_orders = wp_get_attachment_url($orders); should probably look something like this $url_orders = wp_get_attachment_url($order['file-field-name');

  • Okay i Understand and it work thank you 🙂

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.