0

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.

1 Answer 1

1

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.

1
  • thanks for the idea. since I am in plugin development, a solid idea will be very useful. Mar 18, 2012 at 7:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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