get_results( " SELECT MAX(ID) AS post_id FROM {$wpdb->posts} WHERE post_type = 'post' AND post_status = 'publish' GROUP BY post_author ORDER BY post_date_gmt DESC ", ARRAY_A ); if( $return_as_string === true ) { $ids_string = ''; foreach( $recent_ids as $post_id ) { $ids_string .= "{$post_id['post_id']}, "; } // Remove trailing comma $ids_string = substr( $ids_string, 0, -2 ); return $ids_string; } $ids = array( ); foreach( $recent_ids as $post_id ) { $ids[] = $post_id['post_id']; } return $ids; } function prologue_recent_projects_widget( $args ) { extract( $args ); $options = get_option( 'prologue_recent_projects' ); $title = empty( $options['title'] ) ? __( 'Recent Tags' ) : $options['title']; $num_to_show = empty( $options['num_to_show'] ) ? 35 : $options['num_to_show']; $num_to_show = (int) $num_to_show; $before = $before_widget; $before .= $before_title . $title . $after_title; $after = $after_widget; echo prologue_recent_projects( $num_to_show, $before, $after ); } function prologue_recent_projects( $num_to_show = 35, $before = '', $after = '' ) { $cache = wp_cache_get( 'prologue_theme_tag_list', '' ); if( !empty( $cache[$num_to_show] ) ) { $recent_tags = $cache[$num_to_show]; } else { $all_tags = (array) get_tags( array( 'get' => 'all' ) ); $recent_tags = array( ); foreach( $all_tags as $tag ) { if( $tag->count < 1 ) continue; $tag_posts = get_objects_in_term( $tag->term_id, 'post_tag' ); $recent_post_id = max( $tag_posts ); $recent_tags[$tag->term_id] = $recent_post_id; } arsort( $recent_tags ); $num_tags = count( $recent_tags ); if( $num_tags > $num_to_show ) { $reduce_by = (int) $num_tags - $num_to_show; for( $i = 0; $i < $reduce_by; $i++ ) { array_pop( $recent_tags ); } } wp_cache_set( 'prologue_theme_tag_list', array( $num_to_show => $recent_tags ) ); } echo $before; echo "