Skip to content

Instantly share code, notes, and snippets.

@chriscoyier
Created August 22, 2019 00:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chriscoyier/71f74257589de55081bc3aa0cfbced2f to your computer and use it in GitHub Desktop.
Save chriscoyier/71f74257589de55081bc3aa0cfbced2f to your computer and use it in GitHub Desktop.
<?php
class CTF_Register_Taxonomies {
/**
* Initialize the class
*/
public function __construct() {
add_action('init', array( $this, 'tags_support_all') );
add_action('pre_get_posts', array( $this, 'tags_support_query') );
}
public function tags_support_all() {
register_taxonomy_for_object_type('post_tag', 'page');
}
// ensure all tags are included in queries
public function tags_support_query($wp_query) {
if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment