Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 29th, 2012  |  syntax: None  |  size: 1.14 KB  |  hits: 9  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Running a function in Wordpress when publishing a custom post type
  2. function indeedgeo(){
  3.     $indeedgeo = get_post_meta($post>ID, indeedgeo, true);
  4.     $indeedgeos=explode(' ',$indeedgeo);
  5.     $_jr_geo_latitude = $indeedgeos[0];
  6.     $_jr_geo_longitude = $indeedgeos[1];
  7.     update_post_meta($post->ID, _jr_geo_latitude, $_jr_geo_latitude);
  8.     update_post_meta($post->ID, _jr_geo_longitude, $_jr_geo_longitude);
  9.     }
  10. add_action('publish_Jobs', 'indeedgeo');
  11.        
  12. do_action('edit_post', $post_id, $post);
  13. do_action('save_post', $post_id, $post);
  14. do_action('wp_insert_post', $post_id, $post);
  15.        
  16. function se_10441543_save_post($post_id, $post){
  17.     //determine post type
  18.     if(get_post_type( $post_id ) == 'your_post_type'){
  19.         //run your code
  20.         $indeedgeo = get_post_meta($post_id, indeedgeo, true);
  21.         $indeedgeos=explode(' ',$indeedgeo);
  22.         $_jr_geo_latitude = $indeedgeos[0];
  23.         $_jr_geo_longitude = $indeedgeos[1];
  24.         update_post_meta($post_id, _jr_geo_latitude, $_jr_geo_latitude);
  25.         update_post_meta($post_id, _jr_geo_longitude, $_jr_geo_longitude);
  26.     }
  27. }
  28.  
  29. add_action('save_post', 'se_10441543_save_post', 10, 2);