In Drupal most content is stored in nodes, nodes are an inbuilt entity type used to store content. As a developer it is usually the case that you start by defining a number of content types which are specific to the site you're working on, these will be made up of a number of fields and settings specific to the content type you're defining. A content type is essentially just another name for a node type with each new content type your define being a new type of node that users can use to store their content. Find out more about nodes by reading some of our blog posts below...
Read some of our articles about Drupal nodes
In Drupal 7, we had menu_get_object() to get the object in code for whichever node, term, or whatever entity makes up the current page. But in Drupal 8, that has been replaced, and entities can usually be operated on in a generic way. If you know the type of entity you want, it's pretty simple. But I keep running into different suggestions of how to get the entity object when you don't know its type. Given that D8 allows us to deal with entities in a unified way, I thought there must be a good way! The code of core itself is usually the best place to look for examples of how to do common things.
The Drupal admin interface allows you to delete up to 50 nodes at one time, which is great - but there are times when you it's just not enough and you need to bulk delete many thousands of nodes. In this example we will delete all nodes of a particular type (page), a quick way to execute the code is to create a new node, set the input format to PHP, paste the code into...