How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don’t know where WordPress “store” the sticky attribute.
Thanks in advance
How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don’t know where WordPress “store” the sticky attribute.
Thanks in advance
You must be logged in to post a comment.
It’s not stored as attribute, but as list of all stickies. Snippet from core:
So look for the option and then use IDs to retrieve posts.
In raw SQL it would look like this:
It will return string similar to:
Which means that posts with IDs: 27935 and 33322 are “sticky”.
If there are no sticky posts the returned string will look as follows:
For more details about WordPress serialized data structure view https://codex.wordpress.org/Function_Reference/maybe_serialize
Anyway if you are developing custom theme or plugin it’s much better to use snippet provided by @Rarst than writing custom queries.