Category Archive not working for pages

Question

I was wondering if someone could help me out. I have used this function:

function add_taxonomies_to_pages() {

 register_taxonomy_for_object_type( 'category', 'page' );
 }
add_action( 'init', 'add_taxonomies_to_pages' );
 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 );


}

It adds categories to my WordPress pages, but the category archive pages won’t display. I have a category called Association Landing Pages with the slug association-landing-pages. I am developing locally. When I go to localhost/mywordpressitefolder/association-landing-page I am getting a page/file not found error.

0
, , , steamfunk 6 years 2016-10-06T09:32:24-05:00 0 Answers 88 views 0

Leave an answer

Browse
Browse