Compare date of user’s last posts

According to the codex, you’re manipulating get_most_recent_post_of_user()‘s returned value the wrong way. get_most_recent_post_of_user() directly returns the post_date_gmt among blog_id, post_id, and post_gmt_ts. Anyway, if you want to get the 2 last posts of a specific author, use WP_Query instead, which should by default get last posts in the order you need. $author_id = $author_id; $args … Read more

WordPress template next_prev

See: https://codex.wordpress.org/Function_Reference/previous_post_link I’m a little confused by what you are asking but I’m assuming you are after the next/prev links to go to the next or previous post in the same category? In which case, you need to define the third argument in ‘previous_post_link’ & ‘next_post_link’ as ‘true’. Note that those two functions must be … Read more

WordPress post filter

I recommend to hook into the pre_get_posts() function to change the query by adding this code to your functions.php file: <?php function filter_by_date( $query ) { if ( ! is_admin() && $query->is_main_query() ) { if ( isset( $_GET[‘year’] ) ) { $query->set( ‘year’, $_GET[‘year’] ); $query->set( ‘post_type’, ‘events’ ); } } return $query; } add_action( … Read more

Custom author search

Jus add the parameter ‘author__in’=> array( 2, 3, 5 ) to $args and pass the author ID or IDs. You’ll get the results. $args = array( ‘author__in’=> array( 2, 3, 5 ), // array of authors IDs you like to include ‘post_type’ => ‘post’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1 ); And I … Read more