' . wp_kses_post(wpautop(do_shortcode($post_content))) . ''; } } return ''; } add_shortcode('aiocodex', 'aiocodex_generate_new_shortcode'); // Save the shortcode when the post is updated function aiocodex_update_shortcode_on_save($post_id) { if (get_post_type($post_id) !== 'aiocodex') { return; } $shortcode = '[aiocodex id="' . $post_id . '"]'; // No date validation anymore, simply save the shortcode update_post_meta($post_id, '_aiocodex_shortcode', $shortcode); } add_action('save_post', 'aiocodex_update_shortcode_on_save'); // Display shortcode after the title in the editor function aiocodex_display_shortcode_after_title($post) { if (get_post_type($post->ID) !== 'aiocodex') { return; } $shortcode = '[aiocodex id="' . $post->ID . '"]'; if ($shortcode) { echo '
' . esc_html($shortcode) . '