Last active
October 22, 2015 08:24
-
-
Save ville6000/c534251415a90bfcf0c6 to your computer and use it in GitHub Desktop.
Tag support for WordPress pages
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function my_theme_init() { | |
register_taxonomy_for_object_type( 'post_tag', 'page' ); | |
} | |
add_action( 'init', 'my_theme_init' ); | |
function my_theme_tags_support_query( $wp_query ) { | |
if ( $wp_query->get( 'tag' ) ) { | |
$wp_query->set( 'post_type', 'any' ); | |
} | |
} | |
add_action( 'pre_get_posts', 'my_theme_tags_support_query' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment