is_sticky( '17' )
Returns true when Post 17 is considered a sticky post.
@jomsky where would i see in the MySQL database. Lets say I need to find all Sticky post because i’m using it in an application outside of wordpess?
do a database search for ‘sticky’ – this should lead you to the ‘options’ table; column: option_name; row: sticky_posts
http://codex.wordpress.org/Database_Description#Table:_wp_options
example:
$sticks = $wpdb->get_results("SELECT * FROM $wpdb->options WHERE option_name = 'sticky_posts'");
$stickies = unserialize( $sticks[0]->option_value ); //array with the IDs of sticky posts
@alchymyth thanks for your help found it.
The correct way to fetch the sticky data would be to call get_option
which will deal with serialization for you.
$sticky_posts = get_option( 'sticky_posts' );
Ultimately, both should do the same thing though.
@mark – thank you – there is always something new to learn 😉
i was not aware that get_option()
does exactly this.
WordPress does this in various areas using maybe_serialize
and maybe_unserialize
.
http://codex.wordpress.org/Function_Reference/maybe_serialize
http://codex.wordpress.org/Function_Reference/maybe_unserialize
Those functions are used in various areas of WP, users need not serialize and unserialize data, the WordPress functions tend to do this where appropriate, on updating and retrieval.
Serialization only occurs with arrays and objects though, strings are left alone.