Answer the question
In order to leave comments, you need to log in
How to insert likes in wordpress gallery?
Good day. There is a gallery plugin and a likes plugin . The bottom line is that I took the gallery plugin and made a slider out of it (the slider itself was written based on owl carousel 2, I needed the ability to create and edit everything from the admin panel), the site also has the ability to put likes through the second plugin. I shoved the code into the slider, began to rejoice that it worked, but that was not the case. The likes plugin determines the id of the gallery, takes it as a post and enters it into the database, digging around, I found out that it specifically calculates $post->ID, I tried to transfer the record of likes to $attachment->ID, but nothing happened either. in general, I do not know what to do, I will be very very grateful if you help. here is the loop just in case
while ( $second_query->have_posts() ) {
$second_query->the_post(); ?>
<div class="gallery_box_single">
<?php echo do_shortcode( get_the_content() );
$images_id = get_post_meta( $post->ID, '_gallery_images', true );
$posts = get_posts( array(
"showposts" => -1,
"what_to_show" => "posts",
"post_status" => "inherit",
"post_type" => "attachment",
"orderby" => $gllr_options['order_by'],
"order" => $gllr_options['order'],
"post_mime_type" => "image/jpeg,image/gif,image/jpg,image/png",
'post__in' => explode( ',', $images_id ),
'meta_key' => '_gallery_order_' . $post->ID
) );
/*начало*/
if ( 0 < count( $posts ) ) {
$count_image_block = 0; ?>
<div class="gallery">
<div class="owl-carousel slide-two-<? echo $post->ID;?>">
<?php foreach ( $posts as $attachment ) {
$image_attributes = wp_get_attachment_image_src( $attachment->ID, $gllr_options['image_size_photo'] );
$image_attributes_large = wp_get_attachment_image_src( $attachment->ID, 'large' );
$image_attributes_full = wp_get_attachment_image_src( $attachment->ID, 'full' );
$url_for_link = get_post_meta( $attachment->ID, 'gllr_link_url', true );
$image_text = get_post_meta( $attachment->ID, 'gllr_image_text', true );
$image_alt_tag = get_post_meta( $attachment->ID, 'gllr_image_alt_tag', true );
if ( $count_image_block % $gllr_options['custom_image_row_count'] == 0 ) { ?>
<div class="item">
<?php } ?>
<p>
<?php if ( ! empty( $url_for_link ) ) { ?>
<a href="<?php echo $url_for_link; ?>" title="<?php echo $image_text; ?>" target="_blank">
<img <?php if ( $width ) echo 'width="' . $width . '"'; if ( $height ) echo 'height="' . $height . '"'; ?> style="<?php if ( $width ) echo 'width:' . $width . 'px;'; if ( $height ) echo 'height:' . $height . 'px;'; echo $border; ?>" alt="<?php echo $image_alt_tag; ?>" title="<?php echo $image_text; ?>" src="<?php echo $image_attributes[0]; ?>" />
</a>
<?php } else {
if( ! $gllr_options['enable_image_opening'] == 1 ) { ?>
<a data-fancybox="gallery_fancybox<?php if ( 0 == $gllr_options['single_lightbox_for_multiple_galleries'] ) echo '_' . $post->ID; ?>" href="<?php echo $image_attributes_large[0]; ?>" title="<?php echo $image_text; ?>" >
<div class="opencont"> <img width="164px" height="155px" alt="<?php echo $image_alt_tag; ?>" title="<?php echo $image_text; ?>" src="<?php echo $image_attributes[0]; ?>" rel="#"><div class="openwin"><div class="opentext"><?php echo $image_text; ?></div> <?php if(function_exists('wp_ulike')) wp_ulike('get'); ?></div></div>
</a>
<?php } else { ?>
<a data-fancybox="gallery_fancybox<?php if ( 0 == $gllr_options['single_lightbox_for_multiple_galleries'] ) echo '_' . $post->ID; ?>" href="#" style="pointer-events: none;" title="<?php echo $image_text; ?>" >
<img width="164px" height="165px" alt="<?php echo $image_alt_tag; ?>" title="<?php echo $image_text; ?>" src="<?php echo $image_attributes[0]; ?>" rel="#" />
</a>
<?php }
} ?>
</p>
<?php if ( $count_image_block%$gllr_options['custom_image_row_count'] == $gllr_options['custom_image_row_count']-1 ) { ?>
</div>
<?php }
$count_image_block++;
}
if ( 0 < $count_image_block && $count_image_block%$gllr_options['custom_image_row_count'] != 0 ) { ?>
<?php } ?>
</div></div>
<script>
$(document).ready(function() {
$(".slide-two-<? echo $post->ID;?>").owlCarousel({
loop:true, //Зацикливаем слайдер
margin:0, //Отступ от картино если выводите больше 1
nav:true,
rows: true,
autoplayHoverPause:true,
navText : ["<div class='owl-prev1'></div>","<div class='owl-next1'></div>"],
autoplay:true, //Автозапуск слайдера
smartSpeed:600, //Время движения слайда
autoplayTimeout:3000, //Время смены слайда
responsive:{ //Адаптация в зависимости от разрешения экрана
0:{
items:4
},
600:{
items:
6
},
1000:{
items:8
}
}
});
});</script>
<?php }
<?php if(function_exists('wp_ulike')) wp_ulike('get'); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question