Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The following functions.php edit (contributed by helgatheviking on the themeshaper forums) allows the use of a "Read More" link with custom excerpts.

My problem is simply this: I'm inept at editing functions.php code, but I'd like to safely remove the "wrap excerpt in p tag" portion of this script.

How would I do so?

Thanks.

Original script is found here: http://themeshaper.com/forums/topic/enclosing-excerpt-in-paragraph-tag-038-adding-a-custom-read-more-link

// excerpt read more links and wrap excerpt in p tag
function all_excerpts_get_more_link($post_excerpt) {
    return '<p>' . $post_excerpt . '</p>' . '<p class="readmore"><a href="'. get_permalink($post->ID) . '">' . 'Continue Reading &raquo' . '</a></p>';
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
share|improve this question
    
around the "continue reading" or the actual excerpt text –  MartinJJ Jun 25 '11 at 20:47
add comment

2 Answers 2

up vote 1 down vote accepted

This should remove the <p> tags, but leave the styling by replacing the paragraph tag with a <span> class:

function all_excerpts_get_more_link($post_excerpt) {
    return '' . $post_excerpt . '' . '<span class="readmore"><a href="'. get_permalink($post->ID) . '">' . 'Continue Reading &raquo' . '</span>';
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
share|improve this answer
    
Thanks, Jeremy and Javier. The wrapping paragraph tags were introducing validation errors, so I'm glad to be rid of them. –  user5486 Jun 26 '11 at 2:11
add comment

Delete the empty '' it makes no sense on leaving them:

function all_excerpts_get_more_link($post_excerpt) {
    return $post_excerpt . '<span class="readmore"><a href="'. get_permalink($post->ID) . '">' . 'Continue Reading &raquo' . '</span>';
}
add_filter('wp_trim_excerpt', 'all_excerpts_get_more_link');
share|improve this answer
    
I left them in case they wanted to add the surrounding '<p>' tags. Good catch though. Notice I already changed the "p class" to "span class". I wasn't positive which paragraph tag they were referring to so I removed both but left the '' for simple restoration. –  Jeremy Jared Jun 26 '11 at 0:07
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.