WordPress.org

Forums

apply_filters ('the_content' ,$content) Problems (6 posts)

  1. docarzt
    Member
    Posted 2 years ago #

    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?

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

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

  3. docarzt
    Member
    Posted 2 years ago #

    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?

  4. Rebecca O'Brien
    Member
    Posted 2 years ago #

    Why are you using apply_filters, instead of add_filter?

  5. docarzt
    Member
    Posted 2 years ago #

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

  6. esmi
    Forum Moderator
    Posted 2 years ago #

    I'm following the Codex's recommended method

    What method where?

Topic Closed

This topic has been closed to new replies.

About this Topic