Hi Jeff,
Oh, if I only had a team to work with me 😉
Out of the box you can only order by these params.
https://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters
You could possibly write a custom query for this though and pass the post ids to the alm_query_arg filter.
https://connekthq.com/plugins/ajax-load-more/docs/filter-hooks/#alm_query_args
I don’t know how to query for this off hand.
Hope you figure it out.
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..."]