content - Saving Custom Field Data before Publish

admin2025-01-07  3

When creating a page or a post WordPress lets the content (title, body, featured image) be saved when using Ctrl + S. The Custom Fields do not save in the same way (in this case I'm using Advanced Custom Fields as well, but it happens without this plugin).

Does anyone have a solution for saving this data in the same way? In this case Publishing isn't an option.

UPDATE: If I click the "Save draft" button the Custom Fields save. The ctrl + S save only seems to be in scope when in the content area. Is there an easy way to change this to be a global post ctrl S? The "Save Draft" button thankfully removes the urgency, but that would be nice!

When creating a page or a post WordPress lets the content (title, body, featured image) be saved when using Ctrl + S. The Custom Fields do not save in the same way (in this case I'm using Advanced Custom Fields as well, but it happens without this plugin).

Does anyone have a solution for saving this data in the same way? In this case Publishing isn't an option.

UPDATE: If I click the "Save draft" button the Custom Fields save. The ctrl + S save only seems to be in scope when in the content area. Is there an easy way to change this to be a global post ctrl S? The "Save Draft" button thankfully removes the urgency, but that would be nice!

Share Improve this question edited Jul 30, 2013 at 20:15 ArleyM asked Jul 25, 2013 at 16:40 ArleyMArleyM 2032 silver badges8 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I just wrote a plugin that does just that. It's been submitted to the WordPress.org plugin repo earlier this week and hopefully should make an appearance soon. The plugin is officially in the WordPress.org repo. In short what you are looking for is a way to have the following code available on your post editor:

jQuery(window).bind('keydown', function(event) {
    if (event.ctrlKey || event.metaKey) {
        if(String.fromCharCode(event.which).toLowerCase() === 's' ) {
            event.preventDefault();

            if ( typeof wpkeysave_save_trigger !== 'undefined' ){
                // harsh way to save draft/publish/update
                jQuery( '#' + wpkeysave_save_trigger ).trigger( 'click' );
            }

        }
    }
});

Update: The plugin is officially in the WordPress.org repo and will be actively maintained.

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1736263835a921.html

最新回复(0)