Gibt es einen save_post-Hook für benutzerdefinierte Post-Typen?
2 Antworten
- Stimmen
-
- 2012-08-29
der Hookist dergleiche
save_post
stellen Sienur sicher,dasses sich um Ihren Post-Typ handelt,z. B.:add_action('save_post','save_post_callback'); function save_post_callback($post_id){ global $post; if ($post->post_type != 'MY_CUSTOM_POST_TYPE_NAME'){ return; } //if you get here then it's your post type so do your thing.... }
the hook is the same
save_post
just make sure its your post type ex:add_action('save_post','save_post_callback'); function save_post_callback($post_id){ global $post; if ($post->post_type != 'MY_CUSTOM_POST_TYPE_NAME'){ return; } //if you get here then it's your post type so do your thing.... }
-
- 2014-03-08
Neue Lösung ab WP 3.7:
save_post_{$post_type}
add_action( 'save_post_my_post_type', 'wpse63478_save' ); function wpse63478_save() { //save stuff }
Siehe den Hinweis auf der Codex-Seite
New solution, as of WP 3.7:
save_post_{$post_type}
add_action( 'save_post_my_post_type', 'wpse63478_save' ); function wpse63478_save() { //save stuff }
See the note on the codex page
-
Dieneuen Dokumente hierfürfinden Sie hier: https://developer.wordpress.org/reference/hooks/save_post_post-post_type/the new docs for this can be found here: https://developer.wordpress.org/reference/hooks/save_post_post-post_type/
- 2
- 2019-08-06
- Ken
Gibteseinen
save_post
-Hookfürbenutzerdefinierte Post-Typen?Beispiel:
save_my_post_type
Ich weiß,dasses
publish_my_post_type
gibt,aberich suchenacheinem sicheren Hook.