Since we only want to modify the query for archive.php and tag.php template, we check for the presence of tag or category query variable.
We make sure that the query is not modified in the admin view. We use the !is_admin() check for this.
Add the following to functions.php
add_action( 'init', 'add_taxonomies_to_pages' );
function add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
register_taxonomy_for_object_type( 'category', 'page' );
}
if ( ! is_admin() ) {
add_action( 'pre_get_posts', 'category_and_tag_archives' );
}
function category_and_tag_archives( $wp_query ) {
$my_post_array = array('post','page');
if ( $wp_query->get( 'category_name' ) || $wp_query->get( 'cat' ) ) $wp_query->set( 'post_type', $my_post_array );
if ( $wp_query->get( 'tag' ) ) $wp_query->set( 'post_type', $my_post_array );
}