问题
I am running the following function in functions.php and the code works and updates the custom fields when the post is edited.
function indeedgeo_edit_post($post_id, $post){
//determine post type
if(get_post_type( $post_id ) == 'job_listing'){
//indeed geo split
$indeedgeo = get_post_meta($post_id, indeedgeo, true);
$indeedgeos=explode(' ',$indeedgeo);
$_jr_geo_latitude = $indeedgeos[0];
$_jr_geo_longitude = $indeedgeos[1];
update_post_meta($post_id, test1, $_jr_geo_latitude);
update_post_meta($post_id, test2, $_jr_geo_longitude);
}
}
add_action('edit_post', 'indeedgeo_edit_post', 10, 2);
However the posts I am wanting to update are actually being imported from an RSS feed by the Autoblogged plugin, which I believe is using XMLRPC to post as these are the hooks it uses:
// WordPress hooks
add_filter('xmlrpc_methods', 'autoblogged_xmlrpc');
add_action("admin_menu", array(&$this, "ab_addAdminPages"));
add_action('shutdown', array(&$this, 'ab_shutdownIntercept'));
add_action('wp_footer', 'ab_footer');
add_action('wp_head', array(&$this, 'on_wp_head'), 1, 1);
add_action('admin_init', array(&$this, 'on_admin_init'), 1);
add_action('admin_print_scripts', array(&$this, 'on_load_plugin_admin_scripts'));
register_activation_hook(__FILE__, "ab_installOnActivation");
My function does not run using the edit_post, save_post or wp_insert_post hooks when these posts are imported from RSS by the plugin. How can I have the function run?
来源:https://stackoverflow.com/questions/10457257/wordpress-function-not-running-when-importing-posts-via-rss