groups

name language licence
Export WordPress tables PHP BSD
SHOW WORDPRESS POST ATTACHMENTS PHP BSD
WORDPRESS GET URL PHP BSD
truncate a wordpress post - PHP - Snipplr PHP BSD
CUSTOM TEMPLATES FOR POSTS IN WORDPRESS PHP BSD
SHOW DIFFERENT AMOUNT OF POSTS ON WORDPRESS HOME PAGE THAN OTHER PAGES PHP BSD
ANAGE MULTIPLE WORDPRESS SITES WITH ONE DATABASE AND ONE CODE BASE PHP BSD
WORDPRESS QUERY POSTS OF CERTAIN CUSTOM FIELD VALUES PHP BSD

< 1 2 3 4 5 6 7 8 9 10 11 12 >



language: PHP
licence: BSD

truncate a wordpress post - PHP - Snipplr

options: view full snippetsend to code collector
//seful if you want to cut off a post at a certain amount of words, since single.php doesn't allow thecontentrss which cuts off at x amount of chars.

<?php
// this can go in functions.php in your theme directory
function word_split_content($words=15) {
$str = get_the_content('');
$a = preg_split("/[\s]+/", $str,$words+1);
$a = array_slice($a,0,$words);
$final_content = join(' ',$a);
echo $final_content;
}
?>
 
<?php get_header(); ?>
 
	
(Continues...)