Timeline for how to execute some code after a post is published in Wordpress
Current License: CC BY-SA 3.0
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Nov 2, 2017 at 7:28 | comment | added | Jesse Vlasveld |
I updated my answer. You should pass the $post_id to your function. You can check the codex page I linked for a further detailed explanation.
|
|
Nov 2, 2017 at 7:26 | history | edited | Jesse Vlasveld | CC BY-SA 3.0 |
added 10 characters in body
|
Nov 2, 2017 at 7:24 | comment | added | fuxia♦ |
save_post fires even when a post is unpublished (set back to draft).
|
|
Nov 2, 2017 at 7:23 | vote | accept | Sinai | ||
Nov 2, 2017 at 7:23 | comment | added | Sinai |
Thank you very much. Final question: if I want to pass arguments to my function I should use add_action( 'save_post', 'your_save_post_function',10,2 ); for a function with two arguments. But how the function is called? for example my arguments are $postID, $status. I mean when the function is called how wordpress knows I need postID as the 1st argument and the $status which is a custom defined variable as the 2nd argument?
|
|
Nov 2, 2017 at 7:15 | comment | added | Jesse Vlasveld |
Nothing in the wp-content folder will be overwritten when WordPress is updated, so you can safely add it to wp-content/themes/your-themes/functions.php file.
|
|
Nov 2, 2017 at 7:09 | comment | added | Sinai |
You mean functions.php is not overwritten when the Wordpress is updated? I only have to insert my function and use add action to add my function and then save the file. Is there anything else should I do to my function work?
|
|
Nov 2, 2017 at 7:05 | history | answered | Jesse Vlasveld | CC BY-SA 3.0 |