Post Excerpt Problem

Discussion in 'BlackWell-WordPress Business Theme.' started by vesity, Sep 14, 2014.

Thread Status:
Not open for further replies.
  1. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Hi. The attached screenshot shows that the post excerpts are not standard. The size of one is bigger and pushing the next row out of alignment.
    Thanks. Post Excerpts.jpg
     
  2. Yogesh

    Yogesh Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,052
    Likes Received:
    41
    Hello Vesity,

    Excerpt function is working fine, you can see that all post have only 20 words in this section.
    But in first blog all 20 words are bigger so it is taking 4 lines and other are taking only 3 lines.
    Use 40-45 words in Excerpt to fix this problem.

    Thanks & Regards
    Yogesh Bhade
     
  3. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Ok. How do I do that?
    More specifically, where is the code that determines the excerpt size? Can I change that to number of characters instead of number of words?
     
  4. Yogesh

    Yogesh Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,052
    Likes Received:
    41
    Hello Vesity,

    Here is the function for excerpt that count character. You can manage this function like put 40 or any no. in place of 20 for showing character in homepage.

    Code:
    function inktheme_excerpt(){
    $excerpt = get_the_content();
    $excerpt = strip_shortcodes($excerpt);
    $excerpt = strip_tags($excerpt);
    $the_str = substr($excerpt, 0, 20);
    return $the_str;
    }
    1. Copy above code and paste it on functions.php file at the end.
    2. Paste this code <?php echo inktheme_excerpt(); ?> in index.php file as shown below in screenshot.

    16sep1.png

    It will resolve your issue.

    Thanks & Regards
    Yogesh Bhade
     
  5. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Hi. Thank you for responding. Unfortunately the code does not work, and has messed up the site.
    1. Just making the changes to index.php messed up site, so I modified it to <?php echo inkthemes_trim_excerpt(); ?> (instead of what you suggested: <?php echo inktheme_excerpt(); ?> ) and it resolved broken site.
    2. I added the code for functions.php, but it broke the site also. Something is wrong with code.
    Thanks.
     
  6. Yogesh

    Yogesh Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,052
    Likes Received:
    41
    Hello,

    Your issue have been fixed.
    Please visit your site. :) ;)

    Thanks & Regards
    Yogesh Bhade
     
  7. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Beautiful - thank you!! :D Where did you put the code for the character count? So I can change it from 20 to another number...
     
  8. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Actually, it looks like it's just back to a word count instead of a character count. :confused:
     
  9. Yogesh

    Yogesh Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,052
    Likes Received:
    41
    Hello Vesity,

    I think you don't need to do anything in this section, now your site is looking good and it is great.

    Thanks & Regards
    Yogesh Bhade
     
  10. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    I'm glad you think so, but the question is how do I get a character count instead of a word count in the excerpt?
     
  11. Yogesh

    Yogesh Guest

    Joined:
    Aug 8, 2014
    Messages:
    2,052
    Likes Received:
    41
    Hello,

    I have added a function in your function.php file ( inktheme_excerpt() ) that is count character, i have set there 100 character for excerpt, you can edit is as your requirement.

    Thanks & Regards
    Yogesh Bhade
     
  12. vesity

    vesity Member

    Joined:
    Oct 3, 2013
    Messages:
    241
    Likes Received:
    0
    Thank you for doing that. It works great!
     
Thread Status:
Not open for further replies.

Share This Page