filtered frontpage EN posts
This commit is contained in:
@@ -48,7 +48,7 @@ $extensionToClassMap = [
|
||||
<div class="advert-item__contact-info">
|
||||
<p class="advert-item__contact-name subtitle-13"><?= $contact['name'] ?></p>
|
||||
<p class="advert-item__contact-position text-13"><?= $contact['position'] ?></p>
|
||||
<p class="advert-item__contact-phone subtitle-13">Тел: <a href="tel:79263663700"> +7 (926) 555 12 64</a></p>
|
||||
<p class="advert-item__contact-phone subtitle-13">Тел: <a href="tel:79263663700"> +7 (926) 366 37 00</a></p>
|
||||
<p class="advert-item__contact-email text-13"><a href="mailto:pr@agroexpert.press">pr@agroexpert.press</a></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -247,10 +247,25 @@ function custom_pagination($query = null)
|
||||
function my_theme_scripts() {
|
||||
|
||||
if (is_front_page() || (is_category() && !is_paged())) {
|
||||
wp_enqueue_script('my-load-more', get_template_directory_uri() . '/js/load-main-scroll.js', array('jquery'), null, true);
|
||||
wp_enqueue_script('my-load-more', get_template_directory_uri() . '/js/load-main-scroll.js', array('jquery'), '1.0.1', true);
|
||||
|
||||
$query_vars = array('post_type' => 'post', 'posts_per_page' => 10);
|
||||
if (is_category()) {
|
||||
|
||||
if (is_front_page()) {
|
||||
|
||||
// Получаем ID категории, которую мы хотим исключить (например, категория с ID 740)
|
||||
$excluded_category_id = 740;
|
||||
|
||||
// Получаем все подкатегории категории с ID 740
|
||||
$excluded_categories = get_categories(array(
|
||||
'child_of' => $excluded_category_id,
|
||||
'fields' => 'ids' // Получаем только ID подкатегорий
|
||||
));
|
||||
|
||||
// Включаем в запрос параметр, чтобы исключить категорию и её подкатегории
|
||||
$query_vars['category__not_in'] = array_merge(array($excluded_category_id), $excluded_categories);
|
||||
|
||||
} elseif (is_category()) {
|
||||
$category = get_queried_object();
|
||||
$query_vars['cat'] = $category->term_id;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ jQuery(function($) {
|
||||
var loading = false;
|
||||
var loadCount = 0;
|
||||
var maxLoads = 5;
|
||||
var mobileThreshold = 768; // Ширина экрана, считаемая мобильной
|
||||
|
||||
function loadMorePosts() {
|
||||
if (loading || loadCount >= maxLoads) return;
|
||||
@@ -10,7 +11,15 @@ jQuery(function($) {
|
||||
var windowHeight = $(window).height();
|
||||
var documentHeight = $(document).height();
|
||||
|
||||
if (scrollTop + windowHeight >= documentHeight - 200) {
|
||||
// Условие для определения, что мы достигли конца страницы
|
||||
var scrollTrigger = (scrollTop + windowHeight >= documentHeight - 200);
|
||||
|
||||
// Дополнительное условие для мобильных устройств
|
||||
if ($(window).width() < mobileThreshold) {
|
||||
scrollTrigger = (scrollTop + windowHeight >= documentHeight - 100); // Изменяем порог для мобильных
|
||||
}
|
||||
|
||||
if (scrollTrigger) {
|
||||
loading = true;
|
||||
|
||||
var data = {
|
||||
@@ -31,8 +40,12 @@ jQuery(function($) {
|
||||
$('.articles-preview').append(data);
|
||||
my_load_more_params.current_page++;
|
||||
loadCount++;
|
||||
|
||||
var titleTags = document.getElementsByTagName('title');
|
||||
var metaTitle = titleTags[0].textContent;
|
||||
var titlePage = metaTitle;
|
||||
|
||||
ym(96621494, 'hit', location.pathname + '?page=' + my_load_more_params.current_page);
|
||||
ym(96621494, 'hit', location.pathname + '?page=' + my_load_more_params.current_page, {title: titlePage, referer: location.pathname});
|
||||
|
||||
if (my_load_more_params.current_page == my_load_more_params.max_page || loadCount >= maxLoads) {
|
||||
$(window).off('scroll', loadMorePosts);
|
||||
|
||||
Reference in New Issue
Block a user