Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using this filter for Custom excerpts

<?php echo excerpt(90); ?>

http://bavotasan.com/2009/limiting-the-number-of-words-in-your-excerpt-or-content-in-wordpress/

but this filter not working in first featured post showing default 55 words

else it's working fine

<?php 
$count = 1;
if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>
<div id="featurd_post">
<div class="ftrd_image">
<?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>   </div>
<div class="fix"></div>
<div class="ftrd_entry">
<h2 class="title">
<a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php  the_title(); ?></a></h2>
<p class="fetrd_entry">**<?php echo excerpt(90); ?>**</p>
<a href="#" title="" class="read_more">(<?php _e('&#2310;&#2327;&#2375; 
&#2346;&#2338;&#2375; ', 'shreshthbharat'); ?>)</a>
</div></div>     
<?php else : ?>

<div id="post">
<div class="post_image">
<?php woo_get_image('image',455,245,' '.$GLOBALS['align']); ?>   </div>
<div class="fix"></div>
<div class="post_entry">
<h2 class="title">
<a href="<?php the_permalink() ?>" rel="bookmark" title=""><?php  the_title(); ?></a></h2>
<p class="fetrd_entry">**<?php echo excerpt(90); ?>**</p>
<a href="#" title="" class="read_more">(<?php _e('&#2310;&#2327;&#2375; 
&#2346;&#2338;&#2375; ', 'shreshthbharat'); ?>)</a>
</div></div>

please guide.

share|improve this question
    
excerpt() is not a core WordPress function. Please include the function definition for excerpt() in your question. –  Chip Bennett Oct 27 '11 at 18:26
    
please have a look bavotasan.com/2009/… –  user8503 Oct 27 '11 at 18:40
    
Please post the code in your question - for posterity, if for no other reason. –  Chip Bennett Oct 27 '11 at 19:25

2 Answers 2

Try to go in a completely different way about that and this code to your functions.php

// Variable excerpt length.
function dynamic_excerpt($length) { // Variable excerpt length. Length is set in characters
global $post;
$text = $post->post_excerpt;
if ( '' == $text ) {
$text = get_the_content('');
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
}
$text = strip_shortcodes($text); // optional, recommended
$text = strip_tags($text); // use ' $text = strip_tags($text,'<p><a>'); ' if you want to keep some tags
$text = mb_substr($text,0,$length).' ...';
echo $text; // Use this is if you want a unformatted text block
//echo apply_filters('the_excerpt',$text); // Use this if you want to keep line breaks
}

Now when ever you want an excerpt in your theme use this line:

<?php dynamic_excerpt(125); ?>

125 is the length of you characters in this case...

Since this uses "mb_substr" its also great when using hebrew / arabic / chinese or any other langaues which has its characters being count differently.. so.. all around the best solution.

Hope this helps...

share|improve this answer

After playing with your code, I don't see any bugs with the excerpt() function.

I am guessing your problem is with your post excerpt - are you sure you have set up the excerpt for your "featured" post to be longer than 90 characters? If you haven't set an excerpt, WordPress will auto-create one for you.

share|improve this answer
    
yeah i have set up the excerpt for "featured" post longer than 90 Words (Not characters) –  user8503 Oct 28 '11 at 3:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.