Cześć,
Mam pewien problem, a mianowicie, jedna pętla foreach sprawdza czy mam galerie zgodnie z warunkiem, druga w niej zaś generuje obrazki. Potrzebuje aby trzecia pętla foreach podstawiała pod każdą kolejne zdjęcie w miejsce a href pobrane z bazy linki, ale za każdym razem podstawia mi ostatni. Nie wiem za bardzo jak ją wpleść w foreache, które generują mi galerie.
function na_get_gallery_image_urls( $post_id ) {
$post = get_post($post_id);
// Make sure the post has a gallery in it
if( ! has_shortcode( $post->post_content, 'gallery' ) )
return;
// Retrieve all galleries of this post
$galleries = get_post_galleries_images( $post );
$title = get_the_title($post_id);
$poster_guid = $wpdb->get_results("SELECT guid from wp_posts WHERE post_name LIKE ('albums-inside-%') ORDER BY guid DESC");
echo '<h3>'. $title .'</h3>';
//pętla pobierająca ostatnie linki
foreach($poster_guid as $posters_guid){
$post_guid;
$post_guid = ($posters_guid->guid);
echo 'last links: ' . $post_guid;
}
// Loop through all galleries found
foreach( $galleries as $gallery ) {
// Loop through each image in each gallery
foreach( $gallery as $image) {
if(is_page( 376 )){
echo '<div class="single-image page-gallery col-md-12 col-sm-12">'; echo '<a href="'.$image.'"><img src="'.$image.'"></a>';
}
elseif(is_page( 5 )){
echo '<div class="single-image page-home col-md-12 col-sm-12">'; echo '<a href="'.$image.'"><img src="'.$image.'"></a>';
}
else{
echo '<div class="single-image page-inside-gallery col-md-3 col-sm-12">'; echo '<a class="foobox" rel="gallery" href="'.$post_guid.'"><img src="'.$image.'"></a>';
}
}
}
}
Ten post edytował memek42 6.08.2019, 11:15:31