0

I have some <!--more--> tags in my posts and they work...to a degree. Instead of doing a hard break after the <!--more--> tag, it continues on to show some of the next paragraph of text followed by a ...

How can I get the <!--more--> tag to be a hard break?

Thanks

example on homepage

4
  • You need to show use how your theme is handling this code-wise.
    – Wyck
    Commented Jan 30, 2013 at 18:50
  • I'm still a wordpress noob, I need to know which code specifically you need to see. Some keywords I can search for?
    – Brian
    Commented Jan 30, 2013 at 19:03
  • review codex.wordpress.org/Function_Reference/the_excerpt
    – Michael
    Commented Jan 30, 2013 at 19:06
  • this seems to be the meat & potatos of the function but I dont know what to modify. maybe you can suggest? $maxchar=(strpos($content, '<!--more-->'))?strpos(preg_replace('/<.*?>/', '', preg_replace('/<!--more-->/','@smt_readmore_tag',$content)), '@smt_readmore_tag'):$maxchar;
    – Brian
    Commented Jan 30, 2013 at 19:18

1 Answer 1

2

The more-Tag have a filter, you can enhance this with a small plugin like the follow example.

<?php
/**
 * Plugin Name: br after more-Tag
 * Description: Add content of var $extra_more after more-Tag
 * Version:     0.0.1
 */

! defined( 'ABSPATH' ) and exit;

add_filter( 'the_content_more_link', 'custom_more_link', 9999 );
function custom_more_link( $more_link ) {

    $extra_more = '<br>'; // here add your break

    return $more_link . $extra_more;
}

If you will replace the more tag with your markup, then use a small plugin and preg_replace.

add_filter( 'the_content', 'fb_more_link' );
function fb_more_link( $content ) {

    // only on single posts
    if ( ! is_single() )
        return $content;

    // adsense code
    $my_content = '<br>';

    // replace more tag
    $content = preg_replace('/<span id\=\"(more\-\d+)"><\/span>/', $my_content, $content);
    return $content;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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