jeudi 7 avril 2016

the_content filter is being applied to get_the_excerpt() too

I am trying to hook the_content WordPress filter, to add some content to post. by using the function below

function _insert_in_post($content){
if (is_single() && !is_admin() && is_main_query()) {
return $content."blah blah";
}
}

add_filter('the_content', '_insert_in_post');

The content is being added, but I am having a problem that it's also being added to my related posts.

The related posts are using the get_the_excerpt() but still the_content is affecting them.

I want it to only apply this filter the_content to single post contents only.

I have tried using is_main_query() condition too, but in vain.

Can anyone help me in this regard please?



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire