Skip to content

Instantly share code, notes, and snippets.

@lelandf
Last active October 8, 2021 20:37
Show Gist options
  • Save lelandf/c9eca5604f55a2e5586e1de1e66dc160 to your computer and use it in GitHub Desktop.
Save lelandf/c9eca5604f55a2e5586e1de1e66dc160 to your computer and use it in GitHub Desktop.
[TEC] Remove events/feed link
<?php
// Might be overengineering this with the str_contains polyfill
// Just checking to see if the string contains "events/feed" before returning null
// @link https://www.php.net/manual/en/function.str-contains.php#Hcom126277
// @link https://developer.wordpress.org/reference/functions/get_post_type_archive_link/
if ( ! function_exists( 'str_contains' ) ) {
function str_contains( string $haystack, string $needle ) {
return empty( $needle ) || strpos( $haystack, $needle ) !== false;
}
}
add_filter( 'post_type_archive_feed_link', function( $link ) {
if ( str_contains( $link, 'events/feed' ) ) {
$link = null;
}
return $link;
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment