You can’t update the post date with the queries because the update would run repeatedly while the post count equals 6. Every time the query is called the post date would be updated.
You can, however, modify the plugin to update the post date when the like button is clicked and the conditions are met.
This is the basic code you would need to update the post date when the post count equals 6.
if ( GetWtiLikeCount($post_id) == 6 ) {
//update date
$time = current_time('mysql');
wp_update_post(
array (
'ID' => $post_id,
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
);
}
You need to add the code into wti_like_post_ajax.php
so that it will be triggered when the like button is clicked. Here it is in context with some of the surrounding code.
if ($can_vote) {
$current_user = wp_get_current_user();
$user_id = (int)$current_user->ID;
if ($task == "like") {
if ($has_already_voted) {
$query = "UPDATE {$wpdb->prefix}wti_like_post SET ";
$query .= "value = value + 1, ";
$query .= "date_time="" . date("Y-m-d H:i:s') . "' ";
$query .= "WHERE post_id = '" . $post_id . "' AND ";
$query .= "ip = '$ip'";
} else {
$query = "INSERT INTO {$wpdb->prefix}wti_like_post SET ";
$query .= "post_id = '" . $post_id . "', ";
$query .= "value="1", ";
$query .= "date_time="" . date("Y-m-d H:i:s') . "', ";
$query .= "ip = '$ip'";
}
if ( GetWtiLikeCount($post_id) == 6 ) {
//update date
$time = current_time('mysql');
wp_update_post(
array (
'ID' => $post_id,
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
);
}
} else {