2

I have a site with a custom post. When I enter that custom post in admin (edit)-page then a form is rendered. This form takes like about 2-3s to render - it's a lot of of values in it - both hidden and not hidden.

When I update this custom post it takes about 2 seconds to update - and after the update it redirects to the custom post and renders the form again, so overall it could take about 8-9 seconds (regeneration of menu, some other stuff that is loaded each time in the wp-admin area).

My question is: Is there any way just to save post data when upate - like hooking ajax-call to UPDATE-button (I really don't have to reload the page cause it doesn't change anything)?

UPDATE: I guess I could something like this (in jQuery)

$( '#publish' ).click( function( e ) {
    e.preventDefault();
    //ajax call to save current postetc.
    //done = alert('post saved');
} );

but would that be right?

0

If all you're wanting to do is save extra post data you should not need jquery or custom ajax. Wordpress has a built in action you can use to achieve this same thing.

add_action( 'save_post', 'save_more_post_meta' );
function save_more_post_meta( $post_id ) {
    //save stuff here
}

If you need help with saving specifics i'll need a little more detail

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.