Created
August 15, 2012 21:52
-
-
Save micahwave/3364024 to your computer and use it in GitHub Desktop.
guest author latest post
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Add the most recent post id to each guest author as meta | |
*/ | |
function time_guest_author_latest_post( $post_id, $post ) { | |
if( $post->post_type == 'post' ) { | |
$guest_id = get_post_meta( $post_id, 'time_guest_author', true ); | |
if( $guest_id ) { | |
// get the guests most recent post id | |
$latest_post_id = get_post_meta( $guest_id, 'time_latest_post_id', true ); | |
if( ( $latest_post_id && $post_id > $latest_post_id ) || !$latest_post_id ) { | |
update_post_meta( $guest_id, 'time_latest_post_id', $post_id ); | |
} | |
} | |
} | |
} | |
add_action( 'save_post', 'time_guest_author_latest_post', 97, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment