WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] apply_filters(); call it or don't? (4 posts)

  1. krimsly
    Member
    Posted 4 years ago #

    Greetings fellow theme coders,

    After hunting around the forums, I discovered that some functions that return post or page content call apply_filters() so that any short tags are parsed and turned into HTML. But, other functions do not apply the filters so you have to call it yourself, like this:

    $content = apply_filters('the_content', $content);

    The WP docs has a cryptic description of what might happen with this behavior in the future (see below). So, I'm wondering what will happen to my theme if I'm calling apply_filters() but that function gets called automatically by WP in a future version. Any thoughts or suggestions?

    Thanks

    -NorthK

    (From
    http://codex.wordpress.org/Template_Tags/the_content#Alternative_Usage):

    "Please note! get_the_content will not have the following done to it and you are advised to add them until the core has been updated:

    <?php
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    ?>

    "

  2. Velojet
    Member
    Posted 4 years ago #

    krimsly:

    So, I'm wondering what will happen to my theme if I'm calling apply_filters() but that function gets called automatically by WP in a future version. Any thoughts or suggestions?

    Simple answer, NorthK: nothing. You can confirm that for yourself just by duplicating those two lines in your code. The only effect will be redundant processing.

    (I ran into the same problem as you when I discovered that my page template - which uses get_the_content() - wasn't interpreting shortcodes. Eventually, I discovered the same reference in the codex as you did.)

    John V

  3. krimsly
    Member
    Posted 4 years ago #

    Thanks John V.

  4. lucian9
    Member
    Posted 4 years ago #

    Thanks alot, this was my problem also and causing problems with shortcodes. However, your code above may not be correct? The codex page you reference has a different str_replace which includes: &-g-t-; - which I can't make appear in this post, it gets stripped out, probably as it did in your post.

Topic Closed

This topic has been closed to new replies.

About this Topic