WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to style differently the content before the link, but in single.php.

To be more specific, all my posts on the homepage only have a summary, and the rest of the text is cut thanks to the use of the more tag. So when I click on "read more" I see the complete post, starting with the summary we previously seen on the homepage. I'd like to differentiate this summary from the rest of the text, adding it some bold for example, to show to the user what he as already read.

Unfortunately I think this is not possible. Is it ?

share|improve this question
up vote 2 down vote accepted

using: http://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior

and the $strip_teaser parameter: http://codex.wordpress.org/Function_Reference/the_content#Usage

in single.php, replace <?php the_content(); ?> with:

<?php if( strpos(get_the_content(), '<span id="more-') ) : ?>
  <div class="before-more">
  <?php global $more; $more=0; the_content(''); $more=1; ?>
<?php endif; ?>     
<?php the_content('', true); ?>
share|improve this answer

I solved this by creating 2 functions to split the_content() in a before and after-function:

class MyClass
     * Echo the content before the <!--more--> tag
    public static function getContentBeforeMore()
        global $more;
        $more = false;
        $more = true;

     * Echo the content after the <!--more--> tag
    public static function getContentAfterMore($removeMoreTag = true)
        $content = get_the_content(null, true);
        $content = apply_filters( 'the_content', $content );
        $content = str_replace( ']]>', ']]&gt;', $content );
        // Remove the empty paragraph with the <span id="more-.."></span>-tag:
            $content = preg_replace('/<p><span id="more-\d+"><\/span><\/p>/m', '', $content);
        echo $content;

In a template it can be used like this:

<p class="intro"><?php MyClass::getContentBeforeMore(); ?></p>

... some other styling, like date or something ...

<?php MyClass::getContentAfterMore(); ?>
share|improve this answer

Your Answer


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.