Excerpt
-
I am trying to add in a “Read More…” link on an excerpt and also limit the length of the excerpt in my functions file to minimize code in my template. For some reason, it’s not limiting the length or adding the “Read More…” link. Am I doing something wrong that I’m not catching?
This is the code block that I got in my functions.php file.
/* ================================================================= Excerpt stuff ================================================================= */ function junavalove_excerpt_length() { return 20; } add_filter( 'excerpt_length', 'junavalove_excerpt_length' ); function junavalove_excerpt_more() { return sprintf( '<a href="%1$s">%2$s</a>', get_permalink( get_the_ID() ), __( 'Read More...') ); } add_filter( 'excerpt_more', 'junavalove_excerpt_more' );
This is what I got on my index.php template.
if ( has_excerpt() ) { the_excerpt(); } else { the_content('Read more...');
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Excerpt’ is closed to new replies.