Your code did work for me; I was able to see pages under the category archive for Association Landing Pages at http://domain.com/category/association-landing-pages
.
It sounds like you need to use the URL:
localhost/mywordpressitefolder/category/association-landing-pages
I noticed that you said that the slug was association-landing-pages
and then you visited localhost/mywordpressitefolder/association-landing-page
(without the s). Make sure to use the right URL based on your slug, and add /category
too, as explained above.
I would also suggest putting your is_admin()
check inside the category_and_tag_archives()
function. I made a couple of other tweaks to the original code too:
function add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'category', 'page' );
}
add_action( 'init', 'add_taxonomies_to_pages' );
function category_and_tag_archives( $wp_query ) {
$my_post_array = array( 'post', 'page' );
if ( ! is_admin() && is_category() && $wp_query->is_main_query() ) {
$wp_query->set( 'post_type', $my_post_array );
}
}
add_action( 'pre_get_posts', 'category_and_tag_archives' );