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

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #13642
    baraanajjar@gmail.com[email protected]
    Participant

    hi 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
    thanks

    #13648
    Anh TranAnh Tran
    Keymaster

    Hello,

    Can you check if you passed the correct post ID? This is the only thing that I guess caused the bug.

    #13657
    baraanajjar@gmail.com[email protected]
    Participant

    Hi 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 like

    global $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 );
    #13658
    baraanajjar@gmail.com[email protected]
    Participant

    Ok 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

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.