Title: substr(the_title()
Last modified: August 19, 2016

---

# substr(the_title()

 *  Resolved [dab4ma](https://wordpress.org/support/users/dab4ma/)
 * (@dab4ma)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/)
 * Hi, in one of topic, esmi, suggest to use substr(the_title(). I try to use this
   with post title at footer vidget, but without effects. Any ideas?
 *     ```
       <div class="bottom-left">
       		<h3><?php _e('Recent Posts'); ?></h3>
       		<ul>
       		<?php $myposts = get_posts('numberposts=6'); foreach($myposts as $post) : ?>
       			<li><a href="<?php the_permalink(); ?>"><?php substr(the_title(), 0, 12); ?> ...</a></li>
       		<?php endforeach; ?>
       		</ul>
       	</div>
       ```
   
 * this giving normal the_title from the table

Viewing 4 replies - 1 through 4 (of 4 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/#post-1579750)
 * try:
 *     ```
       <li><a href="<?php the_permalink(); ?>"><?php substr($post->post_title, 0, 12); ?> ...</a></li>
       ```
   
 *  Thread Starter [dab4ma](https://wordpress.org/support/users/dab4ma/)
 * (@dab4ma)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/#post-1579752)
 * thnks, but no good. this gives only points ‘…’
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/#post-1579756)
 * Try:
 *     ```
       <?php
       global $post;
       $myposts = get_posts('posts_per_pages=6'); foreach($myposts as $post) :
       setup_postdata($post);?>
       <li><a href="<?php the_permalink(); ?>"><?php echo substr(get_the_title(), 0, 12); ?> ...</a></li>
       <?php endforeach; ?>
       ```
   
 *  Thread Starter [dab4ma](https://wordpress.org/support/users/dab4ma/)
 * (@dab4ma)
 * [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/#post-1579762)
 * thnks, it works correctly. 🙂 brgs
 * and now the code looks like
 *     ```
       <div class="bottom-left">
       		<h3><?php _e('Recent Posts'); ?></h3>
   
       <ul>
       		<?php global $post; $myposts = get_posts('posts_per_pages=6'); foreach($myposts as $post) : setup_postdata($post);?>
   
       <li><a>"><?php if ( strlen(get_the_title()) > 26 ) { echo substr(get_the_title(), 0, 26)."..."; } else { the_title(); } ?></a></li>
               <?php endforeach; ?>
       		</ul>
       	</div>
       ```
   
 * couse we don’t want the ‘…’ every time, ya? :))
 * thnks for good guys

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘substr(the_title()’ is closed to new replies.

## Tags

 * [post](https://wordpress.org/support/topic-tag/post/)
 * [title](https://wordpress.org/support/topic-tag/title/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 3 participants
 * Last reply from: [dab4ma](https://wordpress.org/support/users/dab4ma/)
 * Last activity: [16 years, 1 month ago](https://wordpress.org/support/topic/substrthe_title/#post-1579762)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
