I’m trying to use a custom query to get specific post info from the database if the posts are sticky.

Here is the query:

"SELECT ID, post_title, post_author, post_date, option_value
FROM `{$wpdb->prefix}posts`, `{$wpdb->prefix}options`
WHERE post_status = 'publish' AND post_type = 'post'
AND option_name = 'sticky_posts' 
ORDER BY post_date DESC LIMIT 2"

But this query does not work. It returns two posts but not the sticky ones.
Anyone know how to fix this.

Cheers

Read more here: Get sticky posts from database using $wpdb class


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: