How to get category collection in product details page. I've tried using below code but it's not getting the collection. how to get it?
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$category = $objectManager->get('Magento\Framework\Registry')
->registry('current_category');
$categoryProducts = $category->getCategoryProducts($categoryId);
on product detail page you can just call getCategoryCollection function on product's Object to get Category Collection as following :
$_product = $block->getProduct();
$categoryCollection = $_product->getCategoryCollection();