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 have the following snippet of code:

<?php>$more = '.....';?> 
<p class="extra"><?php the_excerpt(); ?></p>

What I am trying to do is append the value of $more to the_excerpt() function but unsure how to do.

I have tried:

<p class="extra"><?php the_excerpt() . $more; ?></p>

but no go.

Any help would be appreciated.

Thanks.
sp.

share|improve this question
add comment

2 Answers 2

function custom_excerpt_more( $more ) {
    return '...'; // <-- your end string
}
add_filter( 'excerpt_more', 'custom_excerpt_more' );

http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_more


The above solution is the preferred, but to make this work:

<p class="extra"><?php the_excerpt() . $more; ?></p>

Change it to:

<p class="extra"><?php the_excerpt(); echo $more; ?></p>
share|improve this answer
add comment

Just echo out the $more after the excerpt:

<p class="extra"><?php the_excerpt(); echo $more; ?></p>

or a better solution would bet the use a filter and leave the template as is, for example your template uses just the_excerpt()

<p class="extra"><?php the_excerpt(); ?></p>


<?php
//and this goes in your theme's functions.php file
add_filter('the_excerpt','my_excerpt_more');
function my_excerpt_more($excerpt){
   return $excerpt. '.....';
}
share|improve this answer
add comment

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.