WordPress выводит дополнительный HTML-код - PullRequest
0 голосов
/ 01 июля 2018

Я создаю тему в WordPress, я новичок, и вместе с изображением выводится HTML, помогите мне решить эту проблему, спасибо.

<?php

            $args = array( 'numberposts' => 4, 'order'=> 'ASC', 'orderby' => 'title', 'category' => '5' );
            $postslist = get_posts( $args );
            foreach ($postslist as $post) :  setup_postdata($post); ?> 

              <li>
              <div class="timeline-image">
                <a href="<?php the_permalink(); ?>">
                  <img class="rounded-circle img-fluid" src="<?php echo the_post_thumbnail(); ?>">
                </a>
              </div>
              <div class="timeline-panel">
                <div class="timeline-heading">
                  <h4 class="subheading text-left"><?php the_title(); ?></h4>
                </div>
                <div class="timeline-body">
                  <p class="text-muted text-justify"><?php the_excerpt(); ?> &nbsp;
                    <a href="readmore.html">Read More >></a>
                  </p>
                </div>
              </div>
            </li>

<?php endforeach; ?>

1 Ответ

0 голосов
/ 01 июля 2018

Вы должны просматривать сообщения как таковые и не использовать foreach:

<?php
$args = array(
   'post_type' => 'post',
   'posts_per_page' => 4,
   'orderby' => 'title',
   'order' => 'ASC',
   'category__in' => 5
);
$loop = new wp_query( $args );
while( $loop->have_rows() ) : $loop->the_row();
?>
   Your article content…
   <h4 class="subheading text-left"><?php the_title(); ?></h4>
<?php endif; ?>

Если вам нужно перебрать другие типы записей, используйте это руководство .

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...