Поддержка WooCommerce Не отображается HTML теги, почему ?

  • Не отображается HTML теги почему ? Должна же быть каждая запись в div а нет сплошником title

    
    add_shortcode( 'test_shortcode', 'test_shortcode_function1' );
    function test_shortcode_function1() {
     $args = array(
            'post_type' => 'product',
            'post_status'   => 'publish',
            'tax_query' => array(
        array(
            'taxonomy' => 'product_cat',
             'field' => 'slug',
            'terms' => 'zapchasti-dlya-hiblow-hp-10-20', 
        )
     ),
    );
      $query = new WP_Query( $args );
     // Цикл
     if ( $query->have_posts() ) {
      while ( $query->have_posts() ) {
       $query->the_post();
       $html ='<div>'.the_title().'</div>';
      }
     }
     else {
      // 
      $html = 'Постов не найдено';
     }
     return $html;
    
Просмотр 1 ответа (всего 1)
  • Модератор Sergey Biryukov

    (@sergeybiryukov)

    Live and Learn

    $html ='<div>'.the_title().'</div>';

    the_title() не возвращает результат в виде строки, а выводит на экран сразу в момент вызова.

    Вам нужна функция get_the_title().

Просмотр 1 ответа (всего 1)
  • Тема «Не отображается HTML теги, почему ?» закрыта для новых ответов.