WordPress.org

Support

Support » Plugins and Hacks » [Resolved] Problem with add_filter while developing a plugin

[Resolved] Problem with add_filter while developing a plugin

Viewing 4 replies - 1 through 4 (of 4 total)
  • UPDATE
    I’ve tried using a flag variable in session in order to execute the update_views only once. But it didn’t resolve the problem.

    Can you please run my code on your WordPress installation? By doing this, I’ll figure if it’s a configuration or coding problem.

    (sorry for my poor English ^^”’ )

    RESOLVED
    The problem was the default action:

    add_action(‘wp_head’, ‘adjacent_posts_rel_link’, 10, 0);

    in the file default-filters.php

    Inside the plugin code I’ve added:

    function remove_next_link(){
      remove_action('wp_head', 'adjacent_posts_rel_link');
    }
    
    add_action('init','remove_next_link',1);

    Now, why this strange behaviour?

    brucesmlee

    @brucesmlee

    FYI:
    in addition to messing up obvious ways of generating page view counts, this is a significant performance hit (single.php loaded twice on nearly every post)

    Spent some time debugging.

    Tracked it to adjacent_posts_rel_link->get_permalink with permalinks set to ‘Month and name’. Inside get_permalink, the call to get_option(‘home’) appears to be the culprit.

    If permalinks are set to default, this does not happen.

    WP version 2.8.5

    Permalinks set to anything other than the default will trigger this action. I’m also seeing the same issue. Pre-loading an entire post just to get the permalink seems a little overkill when WordPress could get that from the wp_posts table using a query.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Problem with add_filter while developing a plugin’ is closed to new replies.
Skip to toolbar