WordPress.org

Support

Support » Themes and Templates » apply_filters ('the_content' ,$content) Problems

apply_filters ('the_content' ,$content) Problems

  • Greetings. I’m trying to add some content to my post via function and it doesn’t seem to work:

    $content = get_the_content();
    $content = strip_shortcodes( $content );
    $content = $content . "Add this text to end of $content";
    $content = apply_filters('the_content', $content);

    if I remove

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

    I get nothing, as expected. However, my added text is not getting tacked on. Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Michael

    @alchymyth

    Forum Moderator

    please post some complete code, like the full filter function.

    That is actually the built in wordpress filter. ‘the_content’

    Strangely if I put:

    print $content

    It works fine and I see the text I added. So I suspect my problem is that

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

    Is ignoring my specification of $content and grabbing the_content from the global query response? Maybe?

    Why are you using apply_filters, instead of add_filter?

    Actually I’m following the Codex’s recommended method for displaying content retrieved with the get_the_content function.

    esmi

    @esmi

    Forum Moderator

    I’m following the Codex’s recommended method

    What method where?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘apply_filters ('the_content' ,$content) Problems’ is closed to new replies.
Skip to toolbar