Problem retrieving image data using image_upload meta field in while loop
Support › General › Problem retrieving image data using image_upload meta field in while loopResolved
- This topic has 3 replies, 2 voices, and was last updated 6 years, 1 month ago by
[email protected].
Viewing 4 posts - 1 through 4 (of 4 total)
-
AuthorPosts
-
March 10, 2019 at 9:12 PM #13642
[email protected]
Participanthi support i am using function in loop to get the main image of image
while i get image of other post using/////////////////////////////inside while loop ///////////////////////////
$main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$post->requesting_post_id ); $main_image = reset( $main_images );
but when i use same function to get id of other post it return blank
$my_main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$post_id ); $my_main_image = reset( $main_images ); $my_main_image i get empty value
please help
thanksMarch 11, 2019 at 9:39 AM #13648Anh Tran
KeymasterHello,
Can you check if you passed the correct post ID? This is the only thing that I guess caused the bug.
March 11, 2019 at 1:17 PM #13657[email protected]
ParticipantHi There i am passing ids correctly it show correctly the problem is the function called second time not work for the post id
also i am using somehting likeglobal $post; if($get_result){ foreach($get_result as $post){ setup_postdata($post); get_template_part( 'template-parts/item/row-my-request-ad-item' ); } } else { echo '0'; }
inside template file have this code
$list_id = get_the_ID(); //////////////////////////get category details/////////////////////////////////////////////////////// $cat_terms = wp_get_post_terms( $post->requesting_post_id, 'list_category', array( 'fields' => 'all','parent'=> 0 ) ); foreach($cat_terms as $cat_term): $term_name = $cat_term->name; $term_image = get_wp_term_image($cat_term->term_id); endforeach; //////////////////////////get category details/////////////////////////////////////////////////////// $additional_detail_value = rwmb_meta( 'additional_detail','',$post->requesting_post_id); $looking_for = rwmb_meta( 'looking_for','',$post->requesting_post_id); $city = rwmb_meta( 'city','',$post->requesting_post_id); ////////////////GET MAIN IMAGE/////////////////////////////////////////////////////////////////////// $main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$post->requesting_post_id ); $main_image = reset( $main_images ); ///////////////////GET ALL IMAGES///////////////////////////////////////////////////////////////// $gallery_images = rwmb_meta( 'gallery_upload', array( 'size' => 'thumbnail' ) ,$post->requesting_post_id ); $count_gallery_images = count($gallery_images); ///////////////////////////////////////REQUESTING POST LISTING DETAILS////////////////////////////////////////////////////////// /////////////////////////MY ITEM MAIN///////////////////////////////////////////////////////////////////////////// $my_main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$list_id ); $my_main_image = reset( $main_images );
March 11, 2019 at 1:31 PM #13658[email protected]
ParticipantOk Thanks I have Fixed I was passing wrong variable in function.
$my_main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$list_id ); $my_main_image = reset( $main_images );
it must be
$my_main_images = rwmb_meta( 'gallery_upload', array( 'size' => 'full', 'limit' => 1 ) ,$list_id ); $my_main_image = reset( $my_main_images );
Thanks
-
AuthorPosts
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.