Site logo

Archived topic

Add categories to Pages

18 replies · Started by Isaac on January 2, 2019

Viewing posts 16–19 of 19

I am sure they had there reasons :)

Guess so...

But if we can have a chopper flying at Mars, this should be a piece of cake ;-)

Two things with this :

Added the Function Code and i get:
1) the JSON Error when saving
--- "Updating failed. The response is not a valid JSON response."
2) No Category Selector on Page

Thoughts?

Here's the Code :

<!--Add Categories to Pages -->
<?php

function add_taxonomies_to_pages() {
register_taxonomy_for_object_type( 'post_tag', 'page' );
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 );

if ( $wp_query->get( 'tag' ) )
$wp_query->set( 'post_type', $my_post_array );
}
?>

Hi there,

where did you add the code ?

This archived topic is closed to new replies.