• On my front page (index.php) I changed the_content to the_excerpt. Now, instead of paragraphs being wrapped in <p> tags, paragraphs displayed on the front page just have a single < br / > tag separating them. This obviously results in an undesirable effect.How can I make the_excerpt retain the formatting? I tried adding “add_filter(‘the_excerpt’, ‘wpautop’);” on a whim, but it didn’t change anything.

    Thanks in advance.

Viewing 5 replies - 1 through 5 (of 5 total)
  • How can I make the_excerpt retain the formatting?

    You could try using the Optional Excerpt box on each Edit Post page to create a hand-crafted excerpt.

    I think the problem is bigger than this.

    I have a filter applied to the_content that looks for ‘{qname}’ in a post and blows it up in to a restaurant name, ratings, review and link to blog post – you can see an example here.

    When I let that filter run on my category pages, which use the_excerpt, the texts are replaced, but the <b> and the <img…> for the rating icons do not come through.

    I tried adding a filter for the_excerpt with higher priority but that did not have an impact.

    But when I deleted the filter for the_content then the filter for the the_excerpt did work perfectly, leaving the bold and images in the output.

    This feels like a bug to me?

    OK, so now I have read the WordPress help files better I see that the_excerpt is supposed to strip out html tags, so perhaps that is the reason for the strange results.

    That said, I’m running the filter on the results of the_excerpt so it should be possible to add html tags at that stage and not lose them, as indeed is the case when I have no filter for the_content also present

    But it seems to be the presence of the the_content filter that is the problem, even though it should be ignored given that there is no call to the_content() on this page.

    @henkholland I tried the plugin you suggested, but I could not attach my filter to the_excerpt_rereloaded. Maybe I missed a trick, but I was being left with my {qnames} that the filter is supposed to build out.

    Sorry pal. I am not a programmer. Filters etc is beyond me. But the_content and the_excerpt both only work on and with the text in the textbox from the post. So not on the title or the metadata etc.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘the_excerpt ditches <p> tags’ is closed to new replies.