@@ -60,8 +60,6 @@ public function handles_type( $type ) {
6060 * @return array
6161 */
6262 public function get_index_links ( $ max_entries ) {
63- global $ wpdb ;
64-
6563 if ( ! $ this ->handles_type ( 'author ' ) ) {
6664 return [];
6765 }
@@ -111,6 +109,7 @@ public function get_sitemap_links( $type, $max_entries, $current_page ) {
111109 $ query = $ this ->repository
112110 ->query_where_noindex ( false , 'user ' , null , $ noindex_authors_with_no_posts )
113111 ->select_many ( 'id ' , 'object_id ' , 'permalink ' , 'object_last_modified ' )
112+ ->where_raw ( '( `canonical` IS NULL OR `canonical` = `permalink` ) ' )
114113 ->order_by_asc ( 'object_last_modified ' )
115114 ->offset ( $ offset )
116115 ->limit ( $ max_entries );
@@ -145,6 +144,7 @@ protected function get_last_object_per_page( $max_entries_per_page ) {
145144 $ query = $ this ->repository
146145 ->query_where_noindex ( false , 'user ' , null , $ noindex_authors_with_no_posts )
147146 ->select ( 'id ' )
147+ ->where_raw ( '( `canonical` IS NULL OR `canonical` = `permalink` ) ' )
148148 ->order_by_asc ( 'object_last_modified ' );
149149
150150 $ users_to_exclude = $ this ->exclude_users ();
@@ -185,6 +185,7 @@ protected function get_last_object_per_page( $max_entries_per_page ) {
185185 ->query_where_noindex ( false , 'user ' , null , $ noindex_authors_with_no_posts )
186186 ->select_expr ( 'MAX(`object_last_modified`) ' , 'most_recently_modified ' )
187187 ->select_expr ( 'COUNT(`id`) ' , 'number_of_authors ' )
188+ ->where_raw ( '( `canonical` IS NULL OR `canonical` = `permalink` ) ' )
188189 ->having_gt ( 'number_of_authors ' , 0 );
189190
190191 if ( is_array ( $ users_to_exclude ) && count ( $ users_to_exclude ) > 0 ) {
0 commit comments