jQuery(document).ready(function($){
$.ajaxSetup({cache:false});
$(document).on('click', ".post-link", function () {
$( ".sidebar" ).toggleClass( "sidebar-slide" );
$( ".content-wrap" ).toggleClass( "content-slide" );
var post_link = $(this).attr("href")+' #content';
$("#single-post-container").html("<div class='loader'></div><span class='tload'>بارگذاری ...</span>");
$("#single-post-container").load($(this).attr("href")+' #content', function(response, status, xhr) { // complete callback
// create a empty div
var div = document.createElement('div');
// fill div with response
div.innerHTML = response;
// take correct part of the response
var ref = $($(div).find('#content').html());
// filter response for script tags
ref.filter('script').each(function () {
// execute the scripts
$.globalEval(this.text || this.textContent || this.innerHTML || '');
});
var mySwiper = $('.swiper-container').swiper({
mode: 'horizontal',
loop: true
})
});
return false;
});
document.addEventListener('DOMContentLoaded', function(){
var mySwiper = $('.swiper-container').swiper({
mode:'horizontal',
loop: true
});
}, false)
});
swiper.appendSlide('<div class="swiper-slide"><img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" /></div>');
swiper.update(true);
Uncaught SyntaxError: Unexpected identifier 'swiper' (at custom.js?ver=6.1.1:25:5)
//post query
$query = new WP_Query( $query_args );
ob_start();
echo ( $pagination_type == 'load_more' ) ? '<div class="am-postgrid-wrapper">' : '';
if( $query->have_posts() ): ?>
<div class="<?php echo esc_attr( "am_post_grid am__col-3 am_layout_{$args['layout']} {$args['animation']} " ); ?>">
<?php while( $query->have_posts()): $query->the_post(); ?>
<!-- Modal -->
<?php if($args['layout'] == "1"){ ?>
<div class="am_grid_col">
<div data-bs-toggle="modal" data-bs-target="#postModal<?php the_ID(); ?>" data-id="<?php the_ID(); ?>" class="am_single_grid"><div class="more-button"><p>Подробнее</p></div>
<div class="am_thumb">
<?php the_post_thumbnail('full'); ?>
</div>
<div class="am_cont">
<h2 class="am__title"><?php echo get_the_title(); ?></h2></a>
<div class="portfolio-price--grid"><?php the_field('quantity-and-price'); ?></div>
</div>
</div>
</div>
<?php } else if( $args['layout'] == 2 ){ ?>
<?php } ?>
<?php endwhile; ?>
</div>
<div class="am_posts_navigation">
<?php
$big = 999999999; // need an unlikely integer
$dataNext = $dataPaged+1;
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$paginate_links = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, $dataPaged ),
'prev_next' => false,
'mid_size' => 2,
'total' => $query->max_num_pages
) );
// Load more button
if( $pagination_type == 'load_more' ){
if( $paginate_links && $dataPaged < $query->max_num_pages ){
echo "<button type='button' data-paged='{$dataPaged}' data-next='{$dataNext}' class='{$args['infinite_scroll']} am-post-grid-load-more trigger'>" . esc_html__( 'Показать еще', 'ajax-filter-posts' )."</button>";
}
} else {
// Paginate links
echo "<div id='am_posts_navigation_init'>{$paginate_links}</div>";
}
?>
</div>
<?php
else:
esc_html_e('No Posts Found','ajax-filter-posts');
endif;
wp_reset_query();
// Wrap close when infinity load
echo ( $pagination_type == 'load_more' ) ? '</div>' : '';
// Echo the results
return ob_get_clean();
}
jQuery(function($) {
function nameFunction()
{
var swiper = new Swiper('.swiper-container', {
slidesPerView: 1,
spaceBetween: 30,
loop: true,
autoplay: false,
delay: 4000,
pagination: {
el: '.swiper-pagination',
clickable: true,
},
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
});
}
$.ajax({
complete: function() {
nameFunction();
}
});
});
<div class="modal" id="postModal<?php the_ID(); ?>" data-id="<?php the_ID(); ?>">
<div class="modal-dialog modal-dialog-centered" style="max-width:70%">
<div class="modal-content">
<div class="modal-body">
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close" style="float:right;border:none;"></button>
<div class="row-popup">
<div class="col-popup-left">
<?php
$images = get_field('gallery');
if( $images ): ?>
<div class="swiper-container">
<div class="swiper-wrapper">
<?php foreach( $images as $image ): ?>
<div class="swiper-slide">
<img src="<?php echo esc_url($image['url']); ?>" alt="<?php echo esc_attr($image['alt']); ?>" />
</div>
<?php endforeach; ?>
</div>
<div class="swiper-pagination"></div>
<div class="swiper-button-next"></i></div>
<div class="swiper-button-prev"></div>
<?php endif; ?>
</div>
</div>
<div class="col-popup-right">
<h5 class="title" ><?php the_field('type')?></h5>
<p class="customer"><?php the_field('customer')?></p>
<p class="review"><?php the_field('review')?></p>
<p class="price"><?php the_field('quantity')?></p>
</div>
</div>
</div>
</div>
</div>
</div>
не навешиваются скрипты на селекторы
верно. Почему плохая идея. чтоб знать на будущее? custom.js
только один раз, и после отработки ajax не срабатывает acf_add_local_field_group(array(
'key' => 'group_62627cd27e77b',
'title' => 'Тип продукции',
'fields' => array(
array(
'key' => 'field_62627cf84fedb',
'label' => 'Рубрики',
'name' => 'product-type',
'type' => 'taxonomy',
'instructions' => '',
'required' => 0,
'conditional_logic' => 0,
'wrapper' => array(
'width' => '',
'class' => '',
'id' => '',
),
'taxonomy' => 'category',
'field_type' => 'checkbox',
'add_term' => 1,
'save_terms' => 1,
'load_terms' => 1,
'return_format' => 'id',
'multiple' => 0,
'allow_null' => 0,
),
),
'location' => array(
array(
array(
'param' => 'post_type',
'operator' => '==',
'value' => 'catalog',
),
),
),
'menu_order' => 0,
'position' => 'side',
'style' => 'default',
'label_placement' => 'top',
'instruction_placement' => 'label',
'hide_on_screen' => array(
0 => 'categories',
),
'active' => true,
'description' => '',
'show_in_rest' => 0,
));