Site icon Hip-Hop Website Design and Development

Get the entity for a route

In WordPress maintenance support plans 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 WordPress maintenance support plans 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.

Source: New feed