Okk I get it from this function:
function gallery_n_id($post_id, $att_id, $filepath, $is_keep_existing_images = '')
{
// The custom field used for the gallery.
$key = '_gallery';
// Retrieve existing gallery values.
$gallery = get_post_meta($post_id, $key, TRUE);
// If gallery is empty declare a new array.
if (empty($gallery)) {
$gallery = array();
}
// Check if the image is in the gallery.
if (!in_array($att_id, $gallery)) {
// If not, add it.
$gallery[] = $att_id;
// Save the new gallery.
update_post_meta($post_id, $key, $gallery);
}
}
add_action('pmxi_gallery_image', 'gallery_n_id', 10, 4);
But when I take the import: in the editing of the entry, the pictures appear but not on the page.
This is code on website to show gallery:
<?php
$images = get_field('gallery');
?>
<?php if($images):?>
<div class="gallery1">
<?php foreach( $images as $image):?>
<a href="<?php echo $image['sizes']['large'];?>" rel="lightbox"><img src="<?php echo $image['sizes']['thumbnail'];?>" alt="<?php echo $image['alt'];?>" class="gallery2"></a>
<?php endforeach;?>
</div>
<?php endif;?>
Another thing. I would like the featured image not to be displayed in the gallery.
Featured image: <obrazek>
Gallery images: <foto0> <foto1> <foto2> <foto3> <foto4> <foto5>
How to do it?
-
This reply was modified 3 years, 12 months ago by marekduse.