1

I have some html:

<div class="container">
<p class="accent">The first paragraph...</p>
<p>The rest of the article...</p>
</div>

I'd like to put "the_excerpt" in the first paragraph (with a special colour / font size) but then have the following text be "normal".

Is there a way to subtract the_excerpt from the_content so the section "The rest of the article" does not repeat the excerpt?

  • 1
    Is the excerpt generated automatically, from the post content? (by stripping tags, shortcodes etc) – onetrickpony Apr 4 '12 at 16:27
  • Actually I used a different method because sometimes there's an excerpt that is "specially" entered...good point – redconservatory Apr 4 '12 at 17:01
4

The key is to use user-defined excerpts, rather than auto-generated excerpts. For example:

<div <?php post_class(); ?>>
<?php
// If post has defined excerpt, output it here
if ( has_excerpt() ) {
    ?>
    <div class="first-paragraph-excerpt">
    <?php the_excerpt(); ?>
    </div>
    <?php
}
// Now output the content
the_content();
?>
</div> <!-- .post -->

You'll need to adapt to your needs, but this will output a div with the Excerpt, if it exists, and then output the content.

0

Maybe doing it with css?

.container p:first {
    font-weight: bold;
}

And the html from your example:

<div class="container">
<p>The first paragraph...</p>
<p>The rest of the article...</p>
</div>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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