| name | language | licence |
|---|---|---|
| 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 |
| WORDPRESS LOAD JQUERY | PHP | BSD |
| WORDPRESS GET CONTENT | PHP | BSD |
| WORDPRESS: LATEST POSTS FROM CATEGORY | PHP | BSD |
< 1 2 3 4 5 6 7 8 9 >
language: PHP
licence: BSD
truncate a wordpress post - PHP - Snipplr
options: view full snippet • send 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(); ?>



library
buttons (3)
wp (93)