Post Title displaying but not in the wrapped HTML I need

I have a custom query to get the post title, permalink, and featured image. However the Post title is displaying but not in the container I want it in. here is the query

     <ul class="updatelist">
                    <?php 
                        $portquery = new WP_Query();
                        $portquery->query(array('cat' => 3, 'posts_per_page' => 2));
                        while ($portquery->have_posts()) : $portquery->the_post(); 
                            echo "<li class='firstupdate'>";
                        ?>
                            <?php  
                                echo '<span class="thumb-title">'.the_title().'</span>';
                            ?>
                            <?php if (has_post_thumbnail( $post->ID ) ): ?>
                                <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
                                <?php 
                                    echo "<br><img src='".$image[0]."' />"; 
                                ?>
                            <?php endif; 

                            echo "</li>";
                            ?>

                    <?php endwhile; ?>
                    <li class="showupdates">
                        <a href="#">More Blog Updates</a>
                    </li>
                </ul>

and here is the output I get

    <ul class="updatelist">
                    <li class="firstupdate">
                                Another Portfolio Post
             <span class="thumb-title"></span>                                                                                                         
            <br>
              <img src="http://localhost/sosboston/wordpress/wp-content/uploads/2011/08/thumb-1.jpg">                               
               </li>                            
                    <li class="firstupdate">
                            Portfolio Post
             <span class="thumb-title"></span>                                                                                                      

              <br>
               <img src="http://localhost/sosboston/wordpress/wp-content/uploads/2011/08/thumb-1.jpg">                                                        
                </li>           

Related posts

Leave a Reply

2 comments

  1. Try and use get_the_title() instead of the_title(), or pass third parameter to the_title() function as false, this solution isn’t tested but I think it should help.