Tag Info

New answers tagged

0

Best method may be JAVASCRIPT: <script type="text/javascript"> var field_id = "My_field_div__ID"; // <----------------- CHANGE THIS var SubmitButton = document.getElementById("save-post") || false; var PublishButton = document.getElementById("publish") || false; if (SubmitButton) {SubmitButton.addEventListener("click", SubmCLICKED, ...


0

For NEW post type 'post' use draft_to_publish action hook: function fpw_post_info( $post ) { if ( 'post' == $post->post_type ) { // echo '<pre>'; print_r( $post ); echo '<br />'; // $meta = get_post_meta( $post->ID ); print_r( $meta ); echo '</pre>'; die(); // your custom code goes here... } } ...


1

wp_insert_post runs when a post is updated as well. If you scan the source you will see numerous blocks of code switching between an update or not an update. In fact, wp_update_post() just passes data, after a little processing, to wp_insert_post() for the bulk of the work. That is why your code runs more than you think it should-- the hook doesn't work as ...


1

add_action("admin_init", "admin_init"); add_action('save_post', 'save_reference_id'); /*** add_meta_box ***/ function admin_init(){ // adding a custom field to post type 'case' add_meta_box("refInfo-meta", "Reference", "meta_options", "case", "side", "high"); } /*** callback ***/ function meta_options(){ ?> <select name="page_id" ...


1

If you are using the save_post action hook; then you can prevent the code from executing during an autosave with the following conditional: function do_not_autosave( $post ) { // Check to see if we are autosaving if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) return; // Rest of the code here } add_action( 'save_post', ...



Top 50 recent answers are included