Warning while using wp_update_post() | WordPress.org

[ad_1]

“Hello, I’m currently developing a WordPress plugin. In this plugin, I’m using the wp_update_post() function to update a post. When I use this function, it runs normally, but I receive the following warning message on my site: Warning: Use of undefined constant WP_POST_REVISIONS – assumed ‘WP_POST_REVISIONS’.

To address this, I used “define(‘WP_POST_REVISIONS’, 3);” which solves the problem. However, when I submit my plugin to WordPress to publish it in their library, they tell me, “Don’t Force Set Limits Globally.”

Here is the code when I update my post:

$updated_page = array (
        'ID'           => $page_id,
        'post_content' => $new_content,
);

wp_update_post ( $updated_page );

Here is the code when I define the maximum number of post revisions :

if (!defined('WP_POST_REVISIONS')) {
        define ('WP_POST_REVISIONS', 3);
} else {  
        $revisions = WP_POST_REVISIONS;
}

I really need help to resolve this issue and publish my plugin in the library. Thank you :)”

  • This topic was modified 1 hour, 27 minutes ago by antoinecaby.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer