Skip to content

Instantly share code, notes, and snippets.

@lgedeon
Created July 11, 2019 18:50
Show Gist options
  • Save lgedeon/99ee6e7c84a1d316ba4895fee00279fa to your computer and use it in GitHub Desktop.
Save lgedeon/99ee6e7c84a1d316ba4895fee00279fa to your computer and use it in GitHub Desktop.
Build a regex pattern to detect taxonomy archive pages
<?php
$taxonomies = get_taxonomies( [], 'objects' );
$rewrites = wp_list_pluck( $taxonomies, 'rewrite' );
$slugs = array_filter( wp_list_pluck( $rewrites, 'slug' ) );
$archive_pattern = sprintf( '~/[%s]/~', implode( '|', $slugs ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment