1

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.

1
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>
| improve this answer | |
1

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. '.....';
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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