Advertisement
digital-workshop

Tags to pages

Oct 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.37 KB | None | 0 0
  1. // add tag support to pages
  2. function tags_support_all() {
  3.     register_taxonomy_for_object_type('post_tag', 'page');
  4. }
  5.  
  6. // ensure all tags are included in queries
  7. function tags_support_query($wp_query) {
  8.     if ($wp_query->get('tag')) $wp_query->set('post_type', 'any');
  9. }
  10.  
  11. // tag hooks
  12. add_action('init', 'tags_support_all');
  13. add_action('pre_get_posts', 'tags_support_query')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement