• Hello, hope someone can point me in the right direction, i’m sure this is possible but after looking around and trying to change the code myself i can’t seem to work it out

    The following piece of code displays my recent posts, I would like it to also limit the amount of characters displayed in case the name of a post is to long.

    <?php
    $how_many=5; //How many posts do you want to show
    require_once(‘wp-config.php’); // Change this for your path to wp-config.php file ?>
    <ol id=”whats-new”>
    <?
    $news=$wpdb->get_results(“SELECT ID,post_title FROM $wpdb->posts
    WHERE post_type=\”post\” AND post_status=\”publish\” ORDER BY post_date DESC LIMIT $how_many”);
    foreach($news as $np){
    printf (“%s”, $np->ID,$np->post_title);
    }?>

    Thanks

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Limiting the amount of characters displayed’ is closed to new replies.