You are applying that filter to every query on the pages matching the conditions or that if
. You need to restrict this to only the main query and make sure that the conditions are only operating on the $q
query passed into the function.
if ($q->is_main_query()
&& $q->is_post_type_archive('inspiration')
&& !is_admin()) {