gravityflow_post_update_post
The gravityflow_post_update_post action allows custom code to be performed after the Update Post step type has completed.
Parameters
Parameter | Type | Definition |
---|---|---|
$post | array | The post which was updated. |
$feed | feed | The feed which was processed. |
$current_step | Gravity_Flow_Step_Feed_Post_Update |
The current step. |
Examples
Example 1 - Update the alt tag for a featured image based on a specific field
add_action( 'gravityflow_post_update_post', 'jo_post_update_featured_alt', 10, 3 ); function jo_post_update_featured_alt( $post, $feed, $step ) { //Adjust for which step(s) you want to update alt tags with if ( ! $step->get_ID() == '33' ) { return; } $post_id = $post['ID']; $thumbnail_id = get_post_thumbnail_id( $post_id ); $entry = $step->get_entry(); if ( $thumbnail_id ) { //Identify based on feed ID which entry field contains the alt text. switch ( $feed['id'] ) : case '1037': $alt_text = $entry['4']; break; case '1038': $alt_text = $entry['150']; break; case '78': $alt_text = $entry['4']; break; default: $alt_text = false; endswitch; if ( $alt_text ) { //Update the _wp_attachment_image_alt meta for the post with the new text. $result = update_post_meta( $thumbnail_id, '_wp_attachment_image_alt', $alt_text ); } } }
Placement
This code should be placed in the functions.php file of your active theme or in a custom functions plugin.