Knowledge Base

Find solutions for top issues, common error messages and troubleshooting guides

Show the Excerpt

http://colorlabs.co/KPob8U

There’s much style to show the content, full content or even excerpt with link. Here’s some example code for each style :

<?php the_content(); ?>

Means that this will show all the content

<?php the_excerpt(); ?><a href="<?php the_permalink() ?>"><?php _e('Read the full story &raquo;','(theme name)'); ?></a>

It will show the excerpt with “Read More” link, you can change the red more text by your own style

There’s another style / function to show the excerpt by your length setting, this might be you can setting how many words that show for the excerpt.Just open theme-functions.php , and add these code function (make sure there’s not the same function for it) :

function excerpt($limit,$text) {
global $post;

$output = $post->post_excerpt;
if ($output!=''){
$excerpt = $output;
}else{
$excerpt = explode(' ',get_the_excerpt(), $limit);
array_pop($excerpt);
$excerpt = implode(" ",$excerpt).$text;
}
echo $excerpt;
}

After you create those function, you can call the excerpt using this code below at the current file :

<?php excerpt(40,''); ?>     /*the example, the excerpt length will show 40 words*/

Contact Us