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 modifying the content using the "the_content" filter. But this filtering is seen in the excerpts also.

Consider the following code,

function modify_content($content = ''){
    return 'HELLO ALL' . $content;
}
add_filter('the_content', 'modify_content');

This works in the main content perfectly.


Filter content in the main post


But,

if you see in the excerpt, the "HELLO ALL" text is printed, which is unwanted. enter image description here


How to avoid or remove the text in the excerpt ??? which is to be added only to the main content ?? I tried changing the priority but it is no use..

Thank you.

share|improve this question
add comment

1 Answer

If there are no manual excerpts added to the Post, Wordpress picks the content itself as excerpt for that Post. You may either put the excerpts for Posts manually or apply_filter('the_excerpt', 'modify_excerpt') and remove the unwanted text from the excerpt. The function code-structure will remain almost the same, with the exception that now you will want to remove the "Hello All" from excerpt.

I hope this helps; let us know if this resolves your issue.

Cheers,

Ruturaaj.

share|improve this answer
    
thanks for the idea. since I am in plugin development, a solid idea will be very useful. –  Aakash Chakravarthy Mar 18 '12 at 7:34
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.