the_title 默认执行了 echo; 而 get_the_title 只是获取 title,并不执行 echo。
所以 the_xxx 通常用在页面 loop 中,而 get_the_xxx 用在 PHP 逻辑中。
1 2 3 4 5 6 7 8 9 10 11 12 | if ($posts->have_posts()) : while ($posts->have_posts()) : $posts->the_post(); ?> <a href="#" class="product col-lg-4"> <?php the_post_thumbnail($size=array(100, 100), $attr=array('alt' => get_the_title(), )); ?> <b><?php the_title(); ?></b> <i><?php the_excerpt(); ?></i> </a> <?php endwhile; endif; |