我正在使用SearchWP Live搜索结合BarbaJS导航一个网站。在页面转换(没有刷新)之后,导航也将被重新添加,这意味着我需要重新插入SearchWP Live搜索。我在文件里找不到办法。
发布于 2022-05-03 13:54:32
基于这个存储库,代码的这一部分在我的场景中工作。
if (typeof jQuery().searchwp_live_search == 'function') {
jQuery('input[data-swplive="true"]').searchwp_live_search();
// Gutenberg integration is based on a body class addition because we don't have the
// ability to manipulate the markup as we do with get_search_form().
if(typeof _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS !== 'undefined' && _SEARCHWP_LIVE_AJAX_SEARCH_BLOCKS) {
jQuery('input.wp-block-search__input').each(function() {
// Append data vars.
jQuery(this).attr('data-swpengine', _SEARCHWP_LIVE_AJAX_SEARCH_ENGINE);
jQuery(this).attr('data-swpconfig', _SEARCHWP_LIVE_AJAX_SEARCH_CONFIG);
// Init live search.
jQuery(this).searchwp_live_search();
});
}
}https://stackoverflow.com/questions/69823776
复制相似问题