Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Created May 17, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/e378c1d6f0a319c3427daae59e8cfb88 to your computer and use it in GitHub Desktop.
Save andrasguseo/e378c1d6f0a319c3427daae59e8cfb88 to your computer and use it in GitHub Desktop.
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