Execute php after post save/update

I believe you should look into status transitions: https://developer.wordpress.org/reference/hooks/transition_post_status/ There are a couple of examples below the explanation on top of the page. Here’s also some example code of mine: add_action( ‘transition_post_status’, ‘nxt_create_news’, 10, 3 ); // Automatically create a news when a wiki post has been published function nxt_create_news($new_status, $old_status, $nxt_wiki_post) { if(‘publish’ === … Read more

Hook when post is set from published to draft?

Yes, these are probably the right calls to use for what you want. I just checked this by adding this to my functions.php: add_action(‘publish_to_draft’, ‘doStuff’); function doStuff() { update_option(‘foo’, ‘bar1’); } Then using the quick edit in the posts list to change a published post to draft, and this hook definitely ran at that point … Read more

Function is printing twice – any suggestions?

After realizing that I was trying to use the same shortcode for two different types of lists, it was easier to just separate them in two different shortcodes. To list all posts and break them up by type: /** * Shortcode for listing all tools matching tags * Usage: [useful-tools-all desc=”true” li=”true” tags=”health, teens”] * … Read more