Custom WordPress Excerpt not adding <p> tags

I’m in a bit of a sticky situation with a custom excerpt function I’m using.

Here’s a link to the Pastebin with the Custom Excerpt Function: http://pastebin.com/gK0AWQbt

Read More

This is the blog index using the function: http://club16.abcguide.com/blog/

Also, the code I’m using here is: <?php echo excerpt(300); ?>

And here’s the post on the single page, with proper formatting: http://club16.abcguide.com/newsletters/jan-2012/

Essentially the excerpt function I’m using isn’t generating my <p> tags around elements, I’m not sure how I can modify the function to have it do this efficiently.

Also, if I can have more control of when the excerpt ends (maybe even per post? If I could make it identify a specific class and cut there..) that would be amazing.

But focusing on the task at hand, I’m in dire need of a solution!

Related posts

Leave a Reply

1 comment

  1. By default excerpt shows first 55 characters and it strips out all html tags. If you want to increase the length of the excerpt function then you can us a filter like one given bellow, just add this code snippet in your functions.php file of your theme and wrap the function call inside a p tag in the index.php file.

    function new_excerpt_length($length) 
    {
        return 300;
    }
    add_filter('excerpt_length', 'new_excerpt_length');
    

    Use the_excerpt() instead of the_excerpt(300) in your index.php file inside the p tag.

    <p class="someclass"> <?php the_excerpt(); ?> </p>