Monday, August 29, 2022
HomeWordPress Developmentplugins - Attempting to uppdate Post_date with no have an effect on

plugins – Attempting to uppdate Post_date with no have an effect on


I’ve been making an attempt to alter the post_date and post_date_gmt through PHP just for Wooommerce Subscripptions utilizing a scheduler but it surely’s not being modified within the backend. Right here is the code I wrote and the frontend for it as properly.

What am I doing improper right here?

                foreach ($schedules as $key => $schedule) {
                    $scheduledPost = get_post($key);

                    if (!empty($scheduledPost)) {
                        $originalDateTs = strtotime($scheduledPost->post_date);
                        $originalGmtDateTs = strtotime($scheduledPost->post_date_gmt);

                        $newDate = date("Y-m-" . $newDay . " H:i:s", $originalDateTs);
                        $gmtDate = get_gmt_from_date($newDate);

                        // Replace Submit
                        wp_update_post([
                            'ID' => $key,
                            'post_date' => $newDate,
                            'post_date_gmt' => $gmtDate
                        ]);

Fontend Day Changer for Subsriptions.

Solely the day will will probably be chosen + 1month will probably be added by the code.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments