Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TEC > Filter out events from the author on the author page
<?php
/*
* Description: Events created by an author appear on the author archives page for that author.
* This snippet filters these out.
* Usage: Paste the below snippet into your active (child) theme's functions.php file
*
* Plugin: The Events Calendar
* Author: Eric
* Last updated: 2021-05-17
*/
function author_archive_search_filter($query) {
if ( ! is_admin() && $query->is_main_query() && $query->is_author() ) {
$query->set( 'post_type', 'post' );
}
return $query;
}
add_action( 'pre_get_posts', 'author_archive_search_filter',999 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment