
Getting the content type using a node id in drupal 8 can be achieved using bundle() function. The following code will return the node object.
$nodeObj = entity_load('node',”Node id here”);
Now, you can use bundle() to get bundle or content type of that node.
$bundle = $entityObj->bundle();
$bundle will have content type name.
Sample code:
$entityObj = entity_load('node',10); $bundle = $entityObj->bundle(); print_r(“Node is of type:” . $bundle);
Result:
Node is of type: article
Category: