• Resolved seraph

    (@seraph)


    When using the <!--more--> tag with WordPress, how do I access the text before the more tag?

    I would really like to restyle that text, eg. larger or serif-fonted.

    I used to use the Excerpt field, but I realised that it would be a lot easier to just use the builtin more tag.

    Cheers.

Viewing 3 replies - 1 through 3 (of 3 total)
  • onseduction

    (@onseduction)

    Maybe you could put that text in span tags?

    Thread Starter seraph

    (@seraph)

    True, but that would be a little less than optimal really wouldn’t it?

    I was pondering doing a preg_match for something that did a match for *<!--more-->, removed it from the post text itself and then created a new var with the contents of the matched text.

    A little involved, but it’d be quite a lot more portable if I decide to not restyle in the future — I’d like to keep extraneous markup to a minimum.

    Thread Starter seraph

    (@seraph)

    Alright, I came up with a pretty easy solution in the end (quite a non-intensive one too). Instead of using the_content() I use this:

    <?php
    $more = strpos($post->post_content, "<!--more-->")+11;
    if($more != "") {
    echo apply_filters('the_content', '<div class="excerpt">'.substr($post->post_content, 0, $more).'</div>');
    echo apply_filters('the_content', substr($post->post_content, $more));
    }
    else
    the_content();
    ?>

    This has the benefit of allowing flexibility, and allows it to hook into the wordpress plugin hooks as well.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Styling the More Text’ is closed to new replies.