Dill Posted December 2, 2022 Share Posted December 2, 2022 Hello! I am making a shortcode to display photos the way I would like. And I can’t transfer photos from the slider plugin, can you tell me please? Here is my code: <?php $_rand = wp_rand(5); $thumbnail = isset($settings['image_size']) && $settings['image_size'] ? $settings['image_size'] : 'tevily_medium'; $post_id = $post['ID']; $ba_post = BABE_Post_types::get_post($post_id); $url = BABE_Functions::get_page_url_with_args($post_id, $_GET); $image = wp_get_attachment_image_src(get_post_thumbnail_id($post_id), $thumbnail); $image_srcs = wp_get_attachment_image_src( get_post_thumbnail_id( $post['ID'] ), $thumbnail ); $arr1 = array(); $arr2 = array(); $i=0; $babe_post = BABE_Post_types::get_post($post->ID); $files = isset($babe_post['images']) ? (array)$babe_post['images'] : array(); foreach ( $files as $file ) { if (is_array($file) && isset($file['image_id']) && $file['image_id']){ $image_full_arr = wp_get_attachment_image_src( $file['image_id'], $full ); $image_thumb_arr = wp_get_attachment_image_src( $file['image_id'], $thumbnail ); $arr2[i] = $image_thumb_arr[0]; $i++; } } $babe_post = BABE_Post_types::get_post($post->ID); ?> <section class="s-top-bunner b-zoom-gallery"> <div class="b-zoom-gallery_main"> <div class="b-zoom-gallery_main_big-image"> <img src="<?php echo esc_url($image[0]) ?>" alt="<?php echo esc_attr( $post['post_title'] ) ?>" class="image1"> </div> <div class="b-zoom-gallery_main_preview-images"> <div class="b-zoom-gallery_main_preview-images_entry"> <img src="<?php echo esc_url($arr2[0]) ?>" alt="<?php echo esc_attr( $post['post_title'] ) ?>" class="image1"> </div> <div class="b-zoom-gallery_main_preview-images_entry"> <img src="<?php echo $image_thumb_arr[0] ?>" alt=""> </div> <div class="b-zoom-gallery_main_preview-images_entry"> <img src="https://wow-paris.com/wp-content/uploads/2022/11/cocktails-top-1-e1668007709619.jpg" alt=""> </div> </div> </div> </section> I can only pass the featured image, but the slider array of photos does not work. ($image[0]) Here is the slider code: ** * Add unitegallery to booking_obj page. * @param array $post - we're looking for $post['images'] array here * @return string */ public static function block_slider($post){ $output = ''; $files = isset($post['images']) ? (array)$post['images'] : array(); if(!BABE_Settings::$settings['unitegallery_remove'] && !empty($files)){ $thumbnail = apply_filters('babe_slider_img_thumbnail', 'thumbnail'); $full = apply_filters('babe_slider_img_full', 'full'); // Loop through them and output an image foreach ( $files as $file ) { if (is_array($file) && isset($file['image_id']) && $file['image_id']){ $image_full_arr = wp_get_attachment_image_src( $file['image_id'], $full ); $image_thumb_arr = wp_get_attachment_image_src( $file['image_id'], $thumbnail ); $description = isset($file['description']) && $file['description'] ? ' data-description="'.$file['description'].'"' : '' ; $output .= ' <img src="'.$image_thumb_arr[0].'" /> '; } } //// end foreach if ($output){ $unitegallery_settings = BABE_Settings::$unitegallery; $js_arr = array(); foreach($unitegallery_settings as $key => $value){ if ($value === null){ $value_str = 'null'; } elseif ($value === true){ $value_str = 'true'; } elseif ($value === false){ $value_str = 'false'; } elseif (is_float($value) || is_int($value)){ $value_str = $value; } else { $value_str = '"'.$value.'"'; } $js_arr[] = $key.':'.$value_str; } $js = implode(', ', $js_arr); $add_class = !empty(BABE_Settings::$settings['content_in_tabs']) ? ' babe_slider_tabs_content' : ''; $output = ' <div class="babe_slider'.$add_class.'" id="unitegallery" style="display:none;"> '.$output.' </div> '; } } return $output; } Here is the slider call: public static function shortcode_item_slideshow( $atts, $content = null ) { global $post; $output = ''; if ( is_single() && $post->post_type == BABE_Post_types::$booking_obj_post_type) { $args = shortcode_atts( array( 'title' => '', ), $atts, 'babe-item-slideshow' ); $babe_post = BABE_Post_types::get_post($post->ID); $output .= BABE_html::block_slider($babe_post); } return $output; } Can you help me? Quote Link to comment https://forums.phpfreaks.com/topic/315609-receiving-an-array-of-photos-from-a-plugin-using-a-shortcode/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.