Do anything on post_status change [duplicate]

Wrong search terms, already found it: function on_all_status_transitions( $new_status, $old_status, $post ) { if ( $new_status != $old_status ) { // A function to perform actions any time any post changes status. } } add_action( ‘transition_post_status’, ‘on_all_status_transitions’, 10, 3 ); https://codex.wordpress.org/Post_Status_Transitions

Action while post is being published

It sounds like you’re looking for the publish_post hook which (per the Codex): Runs when a post is published, or if it is edited and its status is “published”. Action function arguments: post ID. Alternately, there’s save_post which is triggered whenever a post or page is created or updated, which could be from an import, … Read more

Fix incorrect related posts code snippet

Your first problem: Try to write down what you want to do: You do not want to print posts that are already printed. So you have to remember what posts are already printed. In PHP normally an array is a good solution to remember things that are already done. Let’s add an array: $printed_posts = … Read more

WooCommerce Order Status Displays Twice on Order Page

Solved it. I used the plugins_loaded hook, like this: add_action(‘plugins_loaded’,’example_function’); function example_function(){ remove_action(‘manage_shop_order_posts_custom_column’, ‘woocommerce_custom_order_columns’, 2); add_action(‘manage_shop_order_posts_custom_column’, ‘match_order_woocommerce_custom_order_columns’, 2); }