1

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.

  • 1
    That must be a requirement of the theme you are using. Impossible to know why you need to perform such action after the posts are successfully imported. Maybe if you need some code we can check what is happening. – cybmeta Feb 4 '15 at 8:54
  • Most likely the theme is hooked to a save-post-related action that adds some additional fields, which the import isn't triggering. Can you find anything in the theme source that would indicate which fields/terms it's using to display vehicles? – TheDeadMedic Feb 4 '15 at 11:58
  • I'll ask the theme developer and let you know :) – Lucas Young Feb 4 '15 at 22:04
  • Theme developer said "you need to create a function that simulate the click on Update button for all posts.. About the other question, the theme doesn't add any additional fields, there is a function in seek that just update the seek table in database with the info from post." – Lucas Young Feb 6 '15 at 0:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.