Filtering the_content (6 posts)

  1. ek_wals
    Posted 3 years ago #

    I'm running a multiuser network on localhost and encountering strange problems - see http://wordpress.org/support/topic/read-more-tag-not-working
    Here's another one in the hope that it will inspire a 'eureka' moment in someone brighter than I.

    The problem only appears on a localhost multiuser site using several themes, including twenty-twelve. It does not appear on my live multiuser site or a localhost single site.

    I have written a plugin that attaches a filter to the_content.
    The filtering function is, in its debugging incarnation,

    function filter_content ($content) {
        echo 'XX';
        return 'Filter!';

    If the post is "My Post", the result on the home page is:
    My Post"

    --unless I change the priority of the filter to 11 or higher, whence the output is:
    "My Post

    In the first case, the_content() is returning the post and ignoring the output of the filter. In the second case it appends the output of the filter to the post.

    I understand neither behavior.

  2. Where is this filter located? Is the plugin active on all sites or in MU-plugins?

  3. ek_wals
    Posted 3 years ago #

    The filter is in the plugin. The plugin hooks it into the_content using add_filter() (is that what you mean?)

    The MU network has 2 users. Both act the same when they have the plugin enabled. It still fails in one site if the other has the plugin deactivated.

    I don't know the difference between 'active on all sites' and 'active in MU-plugins'
    Under wp-admin/network, the plugin is not network activated and it fails identically if I 'network activate' it.

  4. ek_wals
    Posted 3 years ago #

    The local site uses WAMP 2.2, PHP 5.2.9-2, and SQL 5.5.16, which has all worked with no problems except for a reluctance to change PHP versions.

  5. ek_wals
    Posted 3 years ago #

    And Apache 2.2.21

  6. Close enough :)

    Can you share the code on this one?

Topic Closed

This topic has been closed to new replies.

About this Topic