How can I get more out of `$post` in an `add_action` callback?

Simply use the post ID, provided by $post_id (and stored at $post->ID) to use the various functions WordPress provides to get any extra data related to that post (get_the_terms,get_post_meta etc). Performance wise you suffer no loss by using these functions as opposed to trying to force more data into the $post object (probably the reverse … Read more

Running a function with args in add_action()

No, this cannot work. Haven’t you tested your idea? A simple workaround would be a class: class WPSE_53453_Action_Handler { public $tokens, $payloads; public function process() { $tokens = $this->tokens; $payloads = $this->payloads; // do something awesome } } $WPSE_53453 = new WPSE_53453_Action_Handler; $WPSE_53453->tokens = array ( ‘foo’, ‘bar’ ); $WPSE_53453->payloads=”hello”; add_action( ‘publish_post’, array ( $WPSE_53453, … Read more

update_user_meta not updating

In response to the extended question, i.e. Another question is[…]: It is worth noting that WordPress’ plugin API does not persist between requests – that is to say, any functions associated with actions through WordPress’ add_action() are only associated for the duration of the script’s execution. Each subsequent request served by WordPress must once again … Read more

create 2 custom columns in page edit in Admin panel

functions attached to manage_pages_custom_column get fired for every custom column, you have to check the name of the column within the function to only output data for that specific column: add_action( ‘manage_pages_custom_column’, ‘AddColumnValue’, 10, 2 ); function AddColumnValue( $column_name, $post_id ) { if( ‘thumbnail’ == $column_name ): echo ‘Header Image data here’; elseif( ‘cssColor’ == … Read more