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

标签 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。请帮我。

最佳答案

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

 <?php echo get_the_title(); ?> 


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

<?php the_title();?>

关于php - 在while循环中获取索引php中的帖子标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19856105/

相关文章:

php - 根据来自多列的 LIKE 匹配项数量对 SQL 结果进行排序

mysql - 从 mySQL 数据库中删除列重复的重复行

wordpress - 我在哪里可以找到大量 WordPress 插件?

javascript - 在 Wordpress/PHP 中 Ping 一个 IP - 得到结果

css - 如何去除 Wordpress 登录页面上的表单边框和阴影?

javascript - 使用 jQuery 实时显示隐藏自定义元框

php - 带引用的发电机不工作

javascript - 设置倒计时/计时器在重置后继续或刷新页面后不重置

phpMyEdit 登录失败?

php - zend_call_method_with_N_params