• Resolved Brayne

    (@brayne)


    I want to save a timestamp to postmeta when a comment is made on that post. I just can’t figure out what hook to use when I want to insert the postmeta…

    Any Ideas?

    thanks in advance.

Viewing 1 replies (of 1 total)
  • Thread Starter Brayne

    (@brayne)

    Detective work complete.

    My objective was to do a query_posts using meta_key and meta_value_num based on the most recent comment. So I’m storing a timestamp in the postmeta. Here is the code I can up with and it’s working great.

    function recent_comment_timestamp() {
    	global $comment_post_ID;
    	$meta_key = 'recent_comment_timestamp';
    	$meta_value = time();
    	update_post_meta($comment_post_ID, $meta_key, $meta_value);
    }
    add_action( 'wp_insert_comment', 'recent_comment_timestamp' );
Viewing 1 replies (of 1 total)
  • The topic ‘Need help with a hook’ is closed to new replies.