0

Есть вывод анонса статей. На всем сайте корректно выводится. Но на странице кампании Лейки the_excerpt() выводит контент статьи Лейки.

Пробовал через get_the_excerpt(ID) - безрезультатно.

Наглядно можно посмотреть https://plusr.ru/campaign/ksyushe-makarovoy-iz-derevni-radovicy-t/

<?php
    $args = [
        'showposts' => 2,
        'ignore_sticky_posts' => 1,
        'orderby' => 'date',
        'order' => 'desc',
        'post_type' => 'post',
        'cat' => 850,
        'paged' => $paged,
    ];
    $articles = new WP_Query($args);
?>

<div class="col s12 m4 news_inner">

<?php if ($articles->have_posts()) : ?>
    <?php while ($articles->have_posts()) : $articles->the_post(); ?>

    <a href="<?php the_permalink() ?>"><?php the_post_thumbnail('thumb'); ?></a>
<?php

    
    echo '<div class="news2_date"><span></span><div>' . get_the_date('j F Y') . '</div><span></span></div>';
    the_title(  '<a class="news2_title" href="' . get_permalink() .'">', '</a>' );

    ?>

    <div class="news2_subtitle"><?php get_the_title();?></div>
    <div class="news2_introtext">
        <?php
            $post_id = get_the_ID(); 
            echo get_the_excerpt( $post_id );
        ?>
    </div>

    <div style="clear: both; height: 17px;"></div>
    
<?php
    endwhile;
    wp_reset_postdata();
?>
<?php endif; ?>
7
  • 1
    На главной странице в списке статей выводятся именно анонсы статей. На странице самой статьи она выводится целиком. Об анонсе какой Лейки вы говорите?
    – Quazimorda
    7 окт 2021 в 11:11
  • По ссылке, которую в посте оставил открывается кампания Лейки. В правой части страницы выводятся анонсы 2х статей. Обратите внимание на excerpt у них - это excerpt текста кампании
    – dukonst
    7 окт 2021 в 11:19
  • disk.yandex.ru/i/3-HRLnu9zYtJwQ
    – dukonst
    7 окт 2021 в 11:20
  • что у вас в функции the_secondary_title()?
    – alenkins
    7 окт 2021 в 14:20
  • Не принципиальный момент. Переделал на get_the_title()
    – dukonst
    7 окт 2021 в 16:46

0

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge you have read our privacy policy.

Посмотрите другие вопросы с метками или задайте свой вопрос.