Ecommerce Shopify WordPress Discussion

WordPress > WP All Import > Forcing future (scheduled) post dates to post as "now" on import

If you use WP All Import to import dozens of feeds from say, Youtube, you'll notice time and time again, imported dates that are set into the future, given the UTC timestamp, will result in the post importing as a Scheduled post with a future date. Those won't actually publish for several hours. All I'm trying to do is force any future post to publish with the current date/time (as set in Wordpress timezone setting). In my case, Los Angeles. But I want to allow past dates to import with whatever date is already set. Some feeds you import may even have different timezones so no matter what, I don't care about that, I just want future dates to import as NOW and old dates to import as whatever they are set to. In the WP All Import functions field, I'm using the following: function publish_now($pub_date) { $tz = new DateTimeZone(get_option('timezone_string')); $dt = new DateTime("now", $tz); $current_date = $dt->format('Y-m-d H:i:s'); // If pub date is in the future, use current date. if ($pub_date > $current_date) { return $current_date; } else { return $pub_date; } } This works for future dates but all the older ones import with the current time and date. Is there a better way to do this, preferably from functions.php? I've tried modifying some code found on here to the following: function setup_future_hook() { // Replace native future_post function with replacement remove_action('future_post','_future_post_hook'); add_action('future_post','publish_future_post_now'); } function publish_future_post_now($id) { $timezone = new DateTimeZone( 'America/Los_Angeles' ); $postdate = wp_date("Y-m-d H:i:s", null, $timezone ); $my_args = array( 'ID' => $id, 'post_date' => $postdate ); remove_action('save_post', 'publish_future_post_now'); wp_update_post( $my_args ); add_action('save_post', 'publish_future_post_now'); } add_action('init', 'setup_future_hook'); This didn't work out as expected. It seemed to remove other meta data such as the category. An acceptable solution can be used in functions.php or in WP All Import's Function Editor.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.