I can think of a number of ways to go about doing this. I'm looking for the most efficient way. Menu looks like this:
catArchive1 [num_new_posts] catArchive2 [num_new_posts] catArchive3 [num_new_posts]
^^[num_new_posts] being the number of new posts
Assuming we have a cookie value set for the users last visit $_COOKIE['lastvisit']
.
I could do something like the follow for EACH menu/category
$args = array(
'category' => $cat_id,
'posts_per_page' => -1,
'date_query' => array( 'after' => $_COOKIE['lastvisit'] ),
);
$new_posts = get_posts($args);
$num_posts = count($num_posts); // Number of new posts
Of course, this is another query for each menu item. Any ideas how to combine this into one and still know how many new posts in each category?
lastvisit
? Would require more code to iterate through the result manually but save on the expensive multi-query approach.