Check if new post or update before save_post action

You can achieve this by using the wp_insert_post hook, which is called before the post is saved or updated. Inside this hook, you can check if the post ID exists to determine if it’s an update or a new post. Here’s how you can do it: add_action(‘wp_insert_post’, function ($post_ID, $post, $update) { if (!$update) { … Read more

Custom fields empty after refreshing page

Try adding this save function to see if it saves data function save_custom_artiesten_metabox_on_reload() { global $post; if (isset($_POST[‘oa_datum’]) && isset($_POST[‘oa_aanvang’]) && isset($_POST[‘oa_locatie’]) && isset($_POST[‘oa_toegang_prijs’])) { update_post_meta($post->ID, ‘oa_datum’, sanitize_text_field($_POST[‘oa_datum’])); update_post_meta($post->ID, ‘oa_aanvang’, sanitize_text_field($_POST[‘oa_aanvang’])); update_post_meta($post->ID, ‘oa_locatie’, sanitize_text_field($_POST[‘oa_locatie’])); update_post_meta($post->ID, ‘oa_toegang_prijs’, sanitize_text_field($_POST[‘oa_toegang_prijs’])); } } add_action(‘admin_init’, ‘save_custom_artiesten_metabox_on_reload’);

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)