• Resolved dab4ma

    (@dab4ma)


    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)
  • try:

    <li><a href="<?php the_permalink(); ?>"><?php substr($post->post_title, 0, 12); ?> ...</a></li>
    Thread Starter dab4ma

    (@dab4ma)

    thnks, but no good. this gives only points ‘…’

    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

    (@dab4ma)

    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.