@romancho354

Как отключить заголовок для Custom post type в the_post()?

На каждой странице выводится Custom post type (баннеры) c полями ACF. Получается так, что the_post() переопределяет wp_title().

functions.php
function get_banner($banner) {
    $result = [];
    $args = array(
        'post_type' => 'banners',
        'post_status' => 'publish',
        'public' => true,
        'hierarchical' => false,
        'post_per_page' => 10
    );
    $banners_loop = new WP_Query( $args );
    if ($banners_loop->have_posts()):
        while ( $banners_loop->have_posts() ) : $banners_loop->the_post();
            if( get_field('banner_type') == $banner) {
                $result= [
                    'imageDesktop' => get_field('banner_desktop'),
                    'imageMobile' => get_field('banner_mobile'),
                    'url' => get_field('banner_link'),
                    'urlMobile' => get_field('banner_link_mobile') ? get_field('banner_link_mobile') : get_field('banner_link')
                ];
            }
        endwhile;
        return $result;
    endif;
    wp_reset_postdata();
    wp_reset_query();
}
add_action('init', 'get_banner' );


single.php
$banner300x600 = get_banner('sidebar');

Вопрос как убрать запрос заголовка?
  • Вопрос задан
  • 30 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы