WordPress publish_post hook not getting featured image and meta on first publish, but works on updating title

I don’t know if it’s the Gutenberg editor or if it’s the hook publish_post The hook itself works, and if you used the old WordPress post editor, then the issue in question would not happen. So you can say that it’s the Gutenberg/block editor. why it’s not returning the meta and featured image Because Gutenberg … Read more

Assign category a default post type

I’m also wanting the post to be assigned the post type “Video”. You can’t just change a post to a different Post Type. There is a difference between “Post Type” and “Post Format”. From your examples I assume you would like to change the “Post Format”, as per the codex http://codex.wordpress.org/Function_Reference/set_post_format, you would need to … Read more

Disable auto-save and post revisions from inside a theme or plugin

You mentioned: Is there a way, to do that from within a plugin or a themes functions.php? You may want to try the following code. Just place it inside your theme’s functions.php file. Using it, you do NOT have to alter the wp-config.php file. define(‘WP_POST_REVISIONS’, false); function disable_autosave() { wp_deregister_script(‘autosave’); } add_action(‘wp_print_scripts’, ‘disable_autosave’);

How to: Avoid a bunch of useless Auto Draft ID entries related in posts table and disable autosave feature in ‘post-new.php’?

Read the thread Disable/ Stop “auto-draft” posts on wp-hackers to understand why this is a very bad idea. Let me quote the explanations from @Otto: Auto-drafts exist because of the fact that multiple users can create new posts at the same time. If two people enter post-new at roughly the same moment, then have their … Read more

Trigger save as draft when uploaded image

Is it the page refresh that’s causing the issue, or do you simply want to save the post before it refreshes? If the later then It’s simple enough with js to check if a condition has changed (ie a button click) in the dom and then: jQuery(“input#save-post”).click().prop(‘disabled’, true); This will of course trigger a full … Read more

isSavingPost() for widgets

If the goal is to display the block ID so that the user can get it easily, instead try using a block editor filter to add a panel in the sidebar: From: https://developer.wordpress.org/block-editor/reference-guides/filters/block-filters/#editor-blockedit const { createHigherOrderComponent } = wp.compose; const { Fragment } = wp.element; const { InspectorControls } = wp.blockEditor; const { PanelBody } … Read more