I'm setting up a site which uses a custom vehicle auction theme. Using the WP All Import plugin, an XML file loads vehicle details into the theme, these are a type of post.
In order for vehicles to appear on the front end, you have to go into each vehicle and click the Update button, without making changes. I'd like to automate this. I tried using the Bulk Actions dropdown to edit all of the titles and update, but this didn't work. I need to go into each vehicle post and update it.
Should I use wp_update_post()
in a cron job?
It looks like the vehicles arent actual posts - using get_posts() in the WP API just returns the blog posts, not the vehicles, even though you can edit a vehicle ie post.php?post=11207&action=edit and listing all vehicles has a post_type of vehicle: edit.php?post_type=vehicle and in the menu, the Vehicles menu has the same structure and does the same as the Posts menu I think the theme developer is using the Unyson framework.
include('wp-load.php');
$args = array('numberposts' => '-1', 'post_type'=>'vehicle' );
$postslist = get_posts( $args );
foreach ( $postslist as $post ){
setup_postdata( $post );
echo the_title()."<br />";
wp_update_post( $post );
}
wp_reset_postdata();
This lists the vehicles but does not cause them to be displayed on the front end after update.