Support » Fixing WordPress » Limiting Content and CSS Problems

  • Hello all,

    I am having the worst time trying to limit character count on a site I am designing. I am using this custom fuction which for some reason looks fine on the homepage, but as soon as I select “Older Posts” the CSS gets screwed up. I’m not sure what might be causing this. If I switch back to a regular the_content call everything is fine. Can someone see something in this code that might cause this?

    function content($limit) {
      $content = explode(' ', get_the_content(), $limit);
      if (count($content)>=$limit) {
        array_pop($content);
        $content = implode(" ",$content).'...';
      } else {
        $content = implode(" ",$content);
      }
      $content = preg_replace('/\[.+\]/','', $content);
      $content = apply_filters('the_content', $content);
      $content = str_replace(']]>', ']]>', $content);
      return $content;
    }

    I’d really like to sort this out. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Michael

    (@alchymyth)

    Forum Moderator

    there is nothing in this function that would imply a change of formatting, when going from front page to a paged page.

    the issue is likely to be with something else (possibly in the content of the posts), in which case a link to your site might be helpful to assess the problem.

    there is no indication how you use this function in your code, probably echo content(200); – in which case you might want to try to change this to echo apply_filters('the_content',content(200));

    Thanks for the tip. Not sure if that worked as I broke something else, but I’ll report back. I’m headed out of town for a week but will pick it up when I get back.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Limiting Content and CSS Problems’ is closed to new replies.