Limiting the amount of characters displayed
-
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(“SELECTID
,post_title
FROM $wpdb->posts
WHEREpost_type
=\”post\” ANDpost_status
=\”publish\” ORDER BY post_date DESC LIMIT $how_many”);
foreach($news as $np){
printf (“%s”, $np->ID,$np->post_title);
}?>Thanks
- The topic ‘Limiting the amount of characters displayed’ is closed to new replies.