Tagged: 

Viewing 4 reply threads
  • Author
    Posts
    • #1757
      vincire
      Member

      Hi, how do I get an image displayed on a page?
      I have read through the forum and codex pages but can’t figure it out.

      I have used this to create the cpt image upload:
      ` piklist(‘field’, array(
      ‘type’ => ‘file’
      ,’field’ => ‘portret’
      ,’scope’ => ‘post_meta’
      ,’label’ => __(‘Voeg een portretfoto toe.’,’piklist’)
      ,’description’ => __(‘U kunt een foto uit de mediatheek kiezen of uw eigen uploaden’,’piklist’)
      ,’options’ => array(
      ‘modal_title’ => __(‘Kies hieronder een foto of kies voor Bestanden uploaden’,’piklist’)
      ,’button’ => __(‘Add’,’piklist’)
      )
      ));

      What should I use in a template to get the image displayed?

    • #1760
      Steve
      Keymaster
    • #1772
      vincire
      Member

      Hi Steve, thank you for your answer.

      The images still is’nt displayed. My knowledge of PHP is not sufficient to solve this.
      I have this to display the image uploaded with the cpt code above:

      <?php $image_ids = get_post_meta($post_id, 'portret');   
      		foreach ($image_ids as $image)
      {
        $myupload = get_post($image); 
        $title = $myupload->post_title;
        $description = $myupload->post_content;
        $caption = $myupload->post_excerpt;
       
        echo 'title:' . $title;
        echo 'description:' . $description;
        echo 'caption:' . $caption;
       
        print_r($myupload); // Displays all data
      }
      ?>
    • #1775
      Steve
      Keymaster

      @vincire– Whoops! My fault. The most important piece of data was missing.

      Place this in the foreach loop:
      echo '<img src="' . wp_get_attachment_url( $myupload->ID) . '"/>"';

    • #1786
      vincire
      Member

      Ok I will try this.

      Thank you

Viewing 4 reply threads
  • You must be logged in to reply to this topic.