I’m using bridge (child theme).
I also edited functions.php to add categories to static pages (I should have used a custom post type, which I regret).
At one point, bridge started giving me an error and categories stopped being displayed. Is there any way to solve this?
Here’s the code.
add_action( ‘init’, ‘my_add_pages_categories’ );
function my_add_pages_categories()
{
register_taxonomy_for_object_type( ‘category’, ‘page’ );
}
add_action( ‘pre_get_posts’, ‘my_set_page_categories’ );
function my_set_page_categories( $query )
{
if ( $query->is_category== true && $query->is_main_query()){
$query->set( ‘post_type’, array( ‘post’, ‘page’, ‘nav_menu_item’ ));
}
}
function checkParent($query=null)
{
if (!$query) {
global $wp_query;
$query = $wp_query;
}
$slug = $query->query_vars[‘category_name’];
$cat = get_category_by_slug($slug);
return $cat->parent;
}