Support » Fixing WordPress » the_excerpt() with CSS

  • Hi all,

    I’m looking to make excerpts for posts that show up on my main page. Previously, I was using the_content() function, but there were many posts that I didn’t manually add a read more link so now I have to resort to the_excerpt() function.

    I already have the codes and the modifications that I need. However, once I put them on, I noticed 2 problems:
    1- All the CSS in the post were gone. They are literally no new lines, no bolding, no blockquote, no nothing. How can I make the formatting to show up again?
    2- For posts that may already have read more links, it doesn’t show up anymore. Rather the post looks like it ends there, no read more links.

    I’m currently resorting to use the_content() function. So, either I have to find solutions to the 2 problems above, or alternatively, I was wondering if there is an option in the_content() function to specify how many words I can display in the excerpt summary?
    I’ve listed my code below FYI.

    function new_excerpt_length($length) {
    	return 150;
    add_filter('excerpt_length', 'new_excerpt_length');
    function new_excerpt_more($more) {
            global $post;
    	return '<a>ID) . '"> ...Continue Reading ' . get_the_title('', '', false) . '</a>';
    add_filter('excerpt_more', 'new_excerpt_more');


    [Please post code snippets between backticks or use the code button.]

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi


    Forum Moderator

    the_excerpt() always removes all formatting unless the post has a completed Optional Excerpt. Check Twenty Eleven’s functions.php file for a function to add a read more link after excerpts.

    So, um, is there a way I can add a filter to the_content() function to limit the number of words in the excerpt?



    Forum Moderator

    No – the_content() and the_excerpt() are two completely separate functions.

    I understand, but doesn’t the_content() function also provide excerpt function? (such as editing the ‘read more’ text? My only question is, can I use it to create a short excerpt that keeps the formatting and limit the amount of words available in the excerpt as well?

    Try this, particularly, the second one:

    Excerpt or Content Word Limit in WordPress: Redux

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘the_excerpt() with CSS’ is closed to new replies.