How to set up excerpts & "Read More!"

This support request was posted in Flatbase by educenter

Request ID #5144 In Progress
  • Dear Juan,

    Please see below at our layout – the posts do not contain excerpts with the “Read More” link.

    What part of the PHP code governs this? I would like to make it so that all posts are excerpts, and you click on “Read more” to access the full post.

    Thanks for your help..

    Andrés Villarreal

    Hi,

    You’re gonna need to override the nice_excerpt() PHP function by putting the following code right at the end of your functions.php file, or inside a child theme (http://codex.wordpress.org/Child_Themes):

    function nice_excerpt( $length = 200 ){
    	$nice_excerpt = substr( get_the_excerpt(), 0, $length ); //truncate excerpt according to $len
    	if ( strlen( $nice_excerpt ) < strlen( get_the_excerpt() ) ) {
    		$nice_excerpt = $nice_excerpt . "...";
    	}
    	echo "

    " . $nice_excerpt . "" . "\n"; if ( strlen( get_the_content() ) > $length ) { echo '' . __( 'Continue reading', 'nicethemes' ) . ''; } }

    You can customize the text and markup for the link (printed at the end of the function) to your own needs.

    Please let me know how it goes.

    Best,

    Andrés.

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

You must be logged in to reply to this topic.

Login to your Account

Welcome back! Please log in to your account by filling the fields below:

Forgot?

Not a member? Create a free account.

Create a Free Account

You're 27 seconds away from some awesome WordPress free stuff, benefits and more. Create a free account and have access to our free products, benefits and more!

Already have an account? Log in
Secure Server