correct agrotop rus
This commit is contained in:
@@ -39,7 +39,7 @@ $advertisers = new WP_Query([
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<a href="<?= home_url() ?>" class="articles-preview__show-next">On top</a>
|
<a href="<?= home_url() ?>/en" class="articles-preview__show-next">On top</a>
|
||||||
<div class="articles__spacer-container">
|
<div class="articles__spacer-container">
|
||||||
<div class="articles__spacer"></div>
|
<div class="articles__spacer"></div>
|
||||||
<div class="articles__spacer"></div>
|
<div class="articles__spacer"></div>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ if (!empty($child_categories)) {
|
|||||||
$excluded_category_ids_in = implode(',', array_map('intval', $excluded_category_ids));
|
$excluded_category_ids_in = implode(',', array_map('intval', $excluded_category_ids));
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
$query = $wpdb->prepare("
|
$query = $wpdb->prepare("
|
||||||
SELECT DISTINCT p.ID, p.post_title, p.post_content, m.meta_value AS position
|
SELECT DISTINCT p.ID, p.post_title, p.post_content, m.meta_value AS position
|
||||||
FROM $wpdb->posts p
|
FROM $wpdb->posts p
|
||||||
@@ -25,6 +26,9 @@ $query = $wpdb->prepare("
|
|||||||
AND tt.term_id NOT IN ($excluded_category_ids_in)
|
AND tt.term_id NOT IN ($excluded_category_ids_in)
|
||||||
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
|
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
|
||||||
");
|
");
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
$query = $wpdb->prepare("
|
$query = $wpdb->prepare("
|
||||||
@@ -37,22 +41,48 @@ $query = $wpdb->prepare("
|
|||||||
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
|
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
|
||||||
");*/
|
");*/
|
||||||
|
|
||||||
|
$excluded_category_id = 740;
|
||||||
|
|
||||||
|
// Запрос для получения всех постов с непустым метаполем 'top_participation_position'
|
||||||
|
$query = "
|
||||||
|
SELECT DISTINCT p.ID, p.post_title, p.post_content, m.meta_value AS position
|
||||||
|
FROM $wpdb->posts p
|
||||||
|
INNER JOIN $wpdb->postmeta m ON p.ID = m.post_id
|
||||||
|
WHERE p.post_type = 'post'
|
||||||
|
AND m.meta_key = 'top_participation_position'
|
||||||
|
AND m.meta_value != ''
|
||||||
|
ORDER BY CAST(m.meta_value AS UNSIGNED) ASC
|
||||||
|
";
|
||||||
|
|
||||||
$top_posts = $wpdb->get_results($query);
|
$top_posts = $wpdb->get_results($query);
|
||||||
|
|
||||||
// Вывод результатов
|
|
||||||
if (!empty($top_posts)) {
|
if (!empty($top_posts)) {
|
||||||
|
|
||||||
foreach ($top_posts as $post) {
|
foreach ($top_posts as $post) {
|
||||||
|
// Проверка наличия категории или подкатегории с ID 740
|
||||||
|
$terms = wp_get_post_terms($post->ID, 'category');
|
||||||
|
$exclude = false;
|
||||||
|
foreach ($terms as $term) {
|
||||||
|
if ($term->term_id == $excluded_category_id || $term->parent == $excluded_category_id) {
|
||||||
|
$exclude = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$exclude) {
|
||||||
|
|
||||||
$permalink = get_permalink($post->ID);
|
$permalink = get_permalink($post->ID);
|
||||||
$title = get_the_title($post->ID);
|
$title = get_the_title($post->ID);?>
|
||||||
?>
|
|
||||||
<div class="most-read__link">
|
<div class="most-read__link">
|
||||||
<a href="<?php echo esc_url($permalink); ?>" class="most-read__link-inner text-13 link-icon-after">
|
<a href="<?php echo esc_url($permalink); ?>" class="most-read__link-inner text-13 link-icon-after">
|
||||||
<?php echo esc_html($title); ?>
|
<?php echo esc_html($title); ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
|
||||||
|
<?}
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
echo '<p>Нет просмотренных постов.</p>';
|
|
||||||
}
|
}?>
|
||||||
?>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user