Answer the question
In order to leave comments, you need to log in
What is a slug in development?
Recently I saw the word slug in the source code . I saw it in other places, but I didn’t understand what it means. Google throws out slugs. What it is?
Answer the question
In order to leave comments, you need to log in
Most often, as already written, it occurs in the URL, but still its meaning is a little wider - slug is a unique identifier string that is understandable to a person (as opposed to ID) and contains only "safe" characters:
- 0-9
- a-z
(generally accepted - in lowercase )
- symbol -
- sometimes also a symbol _
Can be used not only in URL for clarity, but also, for example, in queries to the database (primarily at the API level) - after all, it is
more understandable than SELECT * FROM pages WHERE category=126
.
At the API level, it looks like
or $object->get_pages_in_category( 'some-slug' )
.
In general, it is a human-readable unique identifier.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question