• Please bear with me as i am not that php savvy. I have the following code in my site main page. Here i want to limit the words to say 60 ? How do i accomplish that.

    <?php
            /*$how_many=1;
    		require_once('blog/wp-config.php');
    		?>
    
    		<?
    		$news=$wpdb->get_results("SELECT <code>ID</code>,<code>post_title</code>,<code>post_content</code>,<code>post_date</code> FROM $wpdb->posts
    		WHERE <code>post_type</code>=\"post\" AND <code>post_status</code>=\"publish\" ORDER BY post_date DESC LIMIT $how_many");
    		foreach($news as $np){
    		printf ("<a class=\"index_title\" href=\"%s\">%s</a><br /><br />", get_permalink($np->ID),$np->post_title);
    		printf ("<a href=\"%s\">%s</a>", get_permalink($np->ID),$np->post_content);
    		} */?>
    
                <?php
            	$sql = "SELECT * FROM wp_posts WHERE post_type='post' ORDER BY post_date DESC LIMIT 0,1";
            	$result = mysql_query($sql);
    	        $myrow = mysql_fetch_array($result);
            	$blogEntry = stripslashes($myrow["post_title"]);
    			$blogContent = stripslashes($myrow["post_content"]);
    
    			echo "<p><a class=\"index_title\" href=\"/blog\">$blogEntry</a></p>";
    			echo "<p>$blogContent</p>";
    			?>

    Thanks in advance

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

The topic ‘limit word count to a post’ is closed to new replies.