在while循环中获取索引php中的帖子标题

时间:2013-11-08 09:55:41

标签: php wordpress

我有

<?php while ( have_posts() ) : the_post(); ?>
<div class="boxes-third boxes-first">       
      <div class="latestthree">
        <div class="title">
           <?php get_the_title($id); ?> // I am trying to get the post title here but doesn't work
            <span class="titlearrow"></span>
            </div>
            <div class="latestthreeimage">
    <a rel="prettyPhoto" title="<?php get_the_title($id); ?>"> /same here
      <?php the_post_thumbnail(array(300,133)); ?>
    </a></div>
            <div class="text">
             Here i would like to get the excerpt of the post that is no longer than 25 words
             <span class="textarrow"></span>
            </div>
        </div>       
    </div>
<?php endwhile; ?>

我正在尝试做上面提到的,但没有奏效,并且在最后一个没有找到相关信息。我使用的是wp 3.7.1。请帮帮我。

2 个答案:

答案 0 :(得分:3)

您使用了不打印的get_the_title()。要打印标题,请添加额外的echo

 <?php echo get_the_title(); ?> 

或者您可以使用the_title(),也会打印:

<?php the_title();?>

答案 1 :(得分:1)

尝试使用,

the_title(); 

Reference