Adrian
Adrian

Reputation: 2291

Getting the post title in index php in a while loop

I have

<?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; ?>

I am trying to do the above mentioned, but did not worked and on the last one did not find related info. I am using wp 3.7.1. Please help me.

Upvotes: 5

Views: 7849

Answers (2)

Bhumi Shah
Bhumi Shah

Reputation: 9476

You have used get_the_title() which does not print. To print out the title, add an extra echo:

 <?php echo get_the_title(); ?> 

Or you can use the_title(), which also prints:

<?php the_title();?>

Upvotes: 7

Rikesh
Rikesh

Reputation: 26421

Try just using,

the_title(); 

Reference.

Upvotes: 1

Related Questions