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.

Is there an Action/a Filter that runs just after each post/post excerpt is displayed on these 2 pages? I use the_content and get_the_excerpt currently, but the_content causes a conflict with some other plugin (hence executing my function twice so the content is displayed twice) and setting the priority isn't working!

Note: I've tried the_post, but it runs before each post in the loop on these 2 pages.

Update:

My plugin adds a custom markup with icons after the post content using: the_content- for single post/page and as some themes use the_content('Read More') on index/archive pages

get_the_excerpt - for index/archive pages

The plugin Advanced Excerpt adds some options for post excerpts, and allows the user to set the excerpt length from the settings. When the post length is less than the set excerpt length (via AEs settings), my markup is doubled! When I comment out the_content from my code, the conflict goes off, but without the_content how would I make my plugin work on single page/posts and also with some themes which use the_content('Read More') on index/archive pages? I guess it happens because AE calls the_content instead of the_excerpt when the post length is less than the set excerpt length, hence resulting in a double call. I tried setting the priority of my filter function high, so that it runs after AE's filter function, but no luck! Hence trying a workaround! I hope this clears the question!

share|improve this question
    
Please explain the problem you're having with the function being called twice, i'd suggest working to fix that issue instead of working around it(sounds like a plugin or custom code is hooking a filter wrongly). –  t31os Dec 19 '11 at 16:11
    
Edited question... –  Rutwick Gangurde Dec 19 '11 at 17:25
    
I think you should be working with the_content filter instead of the action. –  Barry Carlyon Jul 15 '12 at 17:57
    
Did my answer work for you? –  toscho Jul 29 '12 at 20:11
    
Thanks man! Actually the filter seemed right, the issue was with the quotes and double quotes order, I was putting the html string in double quotes and the attributes in single, when it should be the other way round, fixed it, and the problem disappeared! Accepting your answer! ;) –  Rutwick Gangurde Jul 30 '12 at 5:06

1 Answer 1

up vote 0 down vote accepted

I am not aware of a dedicated action, but you could prevent double processing with an internal cache in your function.

Pseudo code:

function content_filter( $content )
{
    static $cache = array();
    $id           = get_the_ID();

    if ( in_array( $id, $cache ) )
    {
        return $content; // we did this already
    }

    $cache[] = $id;

    return $content . 'your awesome extra';
}
share|improve this answer

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.