- This topic has 2 replies, 2 voices, and was last updated 6 years, 2 months ago by
hyfyn.
Viewing 2 reply threads
-
AuthorPosts
-
-
November 20, 2015 at 11:25 pm #5052
hyfynMemberI am using meta-boxes to upload files then looping through them and displaying them on the front-end. When I remove a file from the meta-box it is still in the loop and results in a Notice: Trying to get property of non-object.
here is my code
//the piklist meta-boxpiklist('field', array( 'type' => 'file', 'field' => 'services_media', 'scope' => 'post_meta', 'label' => __('Add Services Pictures','piklist'), 'description' => __('Upload Pictures for Services.','piklist'), 'help' => 'Upload image(s) to feature in the services section.', 'options' => array( 'modal_title' => __('Add Logos','piklist'), 'button' => __('Add','piklist') ), 'add_more' => false ));//the loop
$image_ids = get_post_meta($post->ID, 'services_media'); // loop through images and display them foreach ($image_ids as $image) { // get values of image $img = get_post($image); $title = $img->post_title; $caption = $img->post_excerpt; $alttext = trim(strip_tags( get_post_meta($image, '_wp_attachment_image_alt', true) )); $description = $img->post_content; // print out image echo '<div class="small-12 medium-4 column '.$caption.'"><img src="' . wp_get_attachment_url($image) . '" alt="'. $alttext . '" /><p>'.$caption.'</p></div>'; } -
November 23, 2015 at 11:59 am #5068
-
November 23, 2015 at 1:06 pm #5079
hyfynMemberThanks Steve, I love the framework and this is the fist issue I have had. I look forward to the new version
-
-
AuthorPosts
Viewing 2 reply threads
- You must be logged in to reply to this topic.