Support » Fixing WordPress » Clear all after the more tag on single articles

  • Hi everyone!

    I am trying to customize the output of my single articles.

    I would like that a <br clear="all"> would be added on each article after the first lines of my article (at the place where I add the more tag)

    At first, I thought that I could just add that into the_content in single.php
    <?php the_content(''<br clear="all">); ?>
    but it does not seem to work.

    Any idea how I could achieve that?

    Thank you for your help!

Viewing 12 replies - 1 through 12 (of 12 total)
  • Do you want it hooked into the more tag?

    Content content content<!--more--><br clear="all">
    More content blah blah blah

    or something else?

    Try with css:

    .morelink{ display:block; clear:both; }

    try this

    global $more;    // Declare global $more (before the loop).
    $more = 1;       // Set (inside the loop) to display all content, including text below more.
    the_content('<br clear="all">');

    Thank you all!

    @ipstenu yes indeed, that’s what I’d like to achieve.

    @sareiodata Thanks, but won’t this rather affect the more link that appears on index.php, instead of single.php

    @maxchirkov Thank you. I will give a try to these 2 solutions, and let you know how that works out!

    ok, coming back.

    I have tried your solution maxchirkov, and it does not seem to change anything I am afraid.

    @sareiodata, your solution indeed styles the “read more” tag appearing on my homepage (index.php).

    The read more tag is inserted in every article like this:
    <p><span id="more-5363"></span></p>
    Where 5363 is the id of the post. If only there was a way to hook something in there directly…

    It should be .more-link { } I thought…

    Working theory. Since this snippet will remove the link, maybe you can tweak it to add the line break?

    function remove_more_jump_link($link) {
    	$offset = strpos($link, '#more-');
    	if ($offset) {
    		$end = strpos($link, '"',$offset);
    	if ($end) {
    		$link = substr_replace($link, '', $offset, $end-$offset);
    	return $link;
    add_filter('the_content_more_link', 'remove_more_jump_link');

    But there is no the_content_more_link filter when viewing a single post. Better, filter the_content and add a unique class to the “more” span using a RegEx replace.

    function add_more_span_class( $content ) {
        $content = preg_replace('/(more-[0-9]+)/', '$1" class="more-span', $content);
        return $content;
    add_filter( 'the_content', 'add_more_span_class');

    Then you can add CSS to make that span clear.

    .more-span {
        display: block;
        clear: both;

    This works for me if I intentionally place the more tag into a post:

    function _my_custom_func($content){
    	global $post;
    		return $content;
    	return str_replace('<span id="more-' . $post->ID . '"></span>', '<h1>more</h1>', $content);
    add_filter('the_content', '_my_custom_func', 12);

    Oops – replace the H1 tag with the <br clear=”all”>… I used h1 so I could see if it works.

    If you do that, the “more” links from archive pages will point to an invalid anchor. Is that what you want?

    Thank you all!

    To avoid the issue with invalid anchors, I simply changed the code provided by maxchirkov a bit:

    function _my_custom_func($content){
    	global $post;
    		return $content;
    	return str_replace('<span id="more-' . $post->ID . '"></span>', '<span id="more-' . $post->ID . '"></span><br clear="all">', $content);
    add_filter('the_content', '_my_custom_func', 12);

    That did the trick! Thank you again!

    I haven’t looked at the specifics of the code for archive pages, but I placed condition to return $content as is if the page is not a single post.

    Also, if you look at the get_the_content() function line #217 – there is no filter or variable within the span tags… so I assumed it’s safe to simply remove them.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Clear all after the more tag on single articles’ is closed to new replies.