I FREAKING GOT IT! BEEN WORKING ON THIS FOR WEEKS AND THEN THE IDEA CAME TO ME!!!
A meta field to search on in wp_postmeta
Here’s the code to put in functions.php
// UPDATE POST META FIELD ON COMMENT
function comment_posted($comment_ID) {
$commentdata = get_comment($comment_ID, ARRAY_A);
$commentString = get_post($commentdata['comment_post_ID']);
$postID = $commentString->ID;
$time = time();
update_post_meta($postID, "last_updated", $time);
}
add_action('comment_post', 'comment_posted');
// END
// ADD POST META FIELD ON POST
function updateMetaField($post_id, $post) {
$time = time();
update_post_meta($post_id, "last_updated", $time);
}
add_action('wp_insert_post', 'updateMetaField', 10, 2);
add_action('edit_post', 'updateMetaField', 10, 2);
//END
Here’s the shortcode…
[ajax_load_more posts_per_page="6" orderby="meta_value_num" order="DESC" meta_key="last_updated" button_label="View More" button_loading_label="Loading Items..."]