$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>php - Remove a div from RSS feed|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

php - Remove a div from RSS feed

matteradmin7PV0评论

If someone can help to remove a div from my RSS feed. I want to remove below code from my RSS feed.

<div class="well"> <a class="btn" href="foo">foo</a></div>

Thanks in advance, Gregory

If someone can help to remove a div from my RSS feed. I want to remove below code from my RSS feed.

<div class="well"> <a class="btn" href="foo">foo</a></div>

Thanks in advance, Gregory

Share Improve this question edited Feb 27, 2019 at 19:40 Krzysiek Dróżdż 25.6k9 gold badges53 silver badges74 bronze badges asked Feb 27, 2019 at 14:50 veggeraveggera 212 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

You can use the_content_feed hook for that. It is used to filter the content of the post after it is retrieved from the database and filtered by "the_content" and before it is sent to RSS reader (or browser).

So here's the code:

add_filter( 'the_content_feed', function ( $content ) {
    $content = str_replace( '<div class="well"> <a class="btn" href="foo">foo</a></div>', '', $content );
    return $content;
} );

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far