• Resolved till

    (@till)


    I wrote a plugin which is supposed to filter my post_content and add if applicable a footer to it. What I am doing is, inside the filter I grab $GLOBALS['wp_query']->post->ID and perform a couple database queries to check if the footer applies to this post.

    It’s nothing special really.

    To apply the filter I did this underneath:
    add_filter('the_content', 'my_filter', 2);
    add_filter('the_excerpt', 'my_filter', 2);

    The problem is – on static content pages (where the filter does not apply anyway), all works well. However, when I am on my blog’s frontpage or on an entry page, it does not display any categories, blogroll and archives.

    I have no idea why.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Kafkaesqui

    (@kafkaesqui)

    Try checking the source of those pages through your browser and see if any error shows up at the location where sidebar appears to end.

    Beyond that, we’d need a lot clearer idea of what your plugin actually does to work out what’s going on here.

    Thread Starter till

    (@till)

    Ok, first of, thanks for your reply. ??

    I’ll try to be more clear.

    This is my filter:
    function my_filter($string_text)
    {
    $post_id = $GLOBALS['wp_query']->post->ID;
    if (empty($post_id))
    {
    return $string_text;
    }
    /*
    query database and check if extra information
    applies to this post.
    */
    $query = "...";
    ...
    if (mysql_num_rows($res) == 0)
    {
    return $string_text;
    }
    $infoObj = mysql_fetch_object($res);
    $string_text.= sprintf(
    '<ul><li>%s</li></ul>',
    $infoObj->foo
    );
    return $string_text;
    }

    So this is what I do.

    Checking the source, I see no HTML or PHP errors. For example, once I activate the filter, the categories are gone missing. But there is no error, it just says “>> No categories” in place where the list should be.

    Any idea?

    Thread Starter till

    (@till)

    I checked the source code of the website again. There’s no error in the HTML. Any other idea? ??

    This is the only filter doing this. The thing is also, I embeded a function to email me from inside the filter, to check the contents on the frontpage which are parsed. Nothing from the sidebar actually gets in there.

    Still, once I enable it on the frontpage as well, categories and static pages disappear. Like I’m overwriting some internal array? ??

    Thread Starter till

    (@till)

    Ok, I found the error.

    Inside my plugin, I opened a connection. And when I closed it, it screwed up the rest of the site. So leaving it open fixed the situation for me. Not sure why though.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘add_filter problem’ is closed to new replies.