WordPress.org

Ready to get started?Download WordPress

Forums

Using pre_post_update to modify $post->post_content doesn't work (1 post)

  1. aneeskA
    Member
    Posted 1 year ago #

    Hi,

    I wrote the following hook to replace the occurrence of "test" with "testing" . But once I press Update button I don't see the content getting updated.

    What am I missing? Can anyone please help me?

    add_action( 'pre_post_update', 'addrelnofollow_link' );

    function addrelnofollow_link ( $postid ) {
    $post = get_post ($postid);
    if ($post) {
    $post->post_content = str_replace("test", "testing", $post->post_content);
    }
    }

    Best regards

    anees k A

Topic Closed

This topic has been closed to new replies.

About this Topic