在一段时间循环中获取索引 php 中的帖子标题



我有

<?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。请帮助我。

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

 <?php echo get_the_title(); ?> 

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

<?php the_title();?>

尝试只使用,

the_title(); 

参考。

最新更新