“Read More” WordPress Plugin Modification?

I have this WP Plugin that I want to edit, but I just can’t figure it out. What this plugin does is it will put a “Read More…” link for each post of the blog page after the first image and the first paragraph. If no image present at the beginning, it will only show the first paragraph and the read more link after that. But I want to make it so that it shows the first 2-3 paragraphs instead of just one. Or even a after the first, say, 300 words. Any help is much appreciated!

  function the_content_with_readmore_link($more_link_text = null, $stripteaser = 0) {
      $content = get_the_content($more_link_text, $stripteaser);
      $content = apply_filters('the_content', $content);
      $content = explode("</p>", $content);


    foreach ($content as $key => $value){

    if  ($value != null || $value != ''){
        if (  !stripos( $content[$key], '<img' )  === false ){
            echo $content[$key];
            for($i = $key+1; $i < count($content); $i++  ){
                echo $content[$i];
                if  ($content[$i] != null || $content[$i] != '') break;
            }
        }
        else{
            for($i = $key; $i < count($content); $i++  ){
                echo $content[$i];
                  if    ($content[$i] != null || $content[$i] !=     '') break;
            }
          } 
          break;                        
      }
      else echo $value;
  }
  echo '&nbsp;<a href="' . get_permalink($post->ID) . '" >Read More ...</a>';
  }
   ?>

Related posts

Leave a Reply

1 comment

  1. Wouldn’t it be easier to just use the “More Tag(1)”?

    There’s a button for it in WordPress when you are editing a post… or, you can use this: <!--more--> wherever you want the “Read More” break to be. The “more” text can be changed to anything you want, as well.

    Just make sure to keep the “more” spot at the beginning, add a space, and then type whatever you want, like this: <!--more But wait, there's more!-->

    Reference:

    1. http://en.support.wordpress.com/splitting-content/more-tag/