Forums

Read More Not Cutting off Excerpt. (7 posts)

  1. teckn1caLity
    Member
    Posted 10 months ago #

    Is there a new glitch or is it just me? Just recently the read more tag isn't cutting off my excerpts correctly. The excerpt is maxed at 30 words, but, if I only type 20 and add a read more tag it still displays content after the read more tag? Is anyone having this issue or does anyone know how to fix it?

  2. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Have you tried:

    - deactivating all plugins to see if this resolves the problem. If this works, re-activate the plugins one by one until you find the problematic plugin(s).

    - switching to the Twenty Eleven theme to rule out any theme-specific problems.

  3. teckn1caLity
    Member
    Posted 10 months ago #

    Just tried it and it's still doing it. This is actually the code im using

    '<?php echo excerpt(50); ?>'

    Edit: I just changed it to 40 words, gonna see how that works even thought it should be automatic when I use a read more tag, no?

  4. esmi
    Theme Diva & Forum Moderator
    Posted 10 months ago #

    Can we see your site using Twenty Eleven?

    And the code you posted above is just plain wrong.
    http://codex.wordpress.org/Function_Reference/the_excerpt

  5. teckn1caLity
    Member
    Posted 10 months ago #

    Actually, I'm using a function I found somewhere. It lets me utilize that code for multiple areas of the site so I can limit the words per each area

    This is the function

    insert: <?php echo excerpt(50); ?>

    <?php
    function excerpt($limit) {
      $excerpt = explode(' ', get_the_excerpt(), $limit);
      if (count($excerpt)>=$limit) {
        array_pop($excerpt);
        $excerpt = implode(" ",$excerpt).'...';
      } else {
        $excerpt = implode(" ",$excerpt);
      }
      $excerpt = preg_replace('<code>\[[^\]]*\]</code>','',$excerpt);
      return $excerpt;
    }
    
    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 would use the function to the link you posted but it only lets me control one excerpt and not multiple. I have areas of my site where I want more content, words in this case, than other areas - if you understand what I'm saying.

  6. alchymyth
    The Sweeper
    Posted 10 months ago #

    even thought it should be automatic when I use a read more tag, no?

    no

    afaik, these codes do not use the 'more tag'.

    I just changed it to 40 words, gonna see how that works

    and how did it work?

  7. teckn1caLity
    Member
    Posted 10 months ago #

    The 40 word minimum has been working fine, I guess that's a good minimum since sometimes I don't type much. Hey Alchy, if you take a look at my recent threads started I made a thread on the YD Recent Posts thumbnails.. can you take a look at my problem? I've been stumped by it for the past 3 days trying to fix it and can't come up with any solutions.

Reply

You must log in to post.

About this Topic

Tags

No tags yet.