Limiting Content and CSS Problems (3 posts)

  1. misterpatrick67
    Posted 6 years ago #

    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) {
        $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!

  2. Michael
    Forum Moderator
    Posted 6 years ago #

    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));

  3. misterpatrick67
    Posted 6 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic