Change Sticky posts from an option field to a meta field in the database

  1. benz001


    Working with Sticky posts currently is very awkward for a theme developer, you can't easily 'float' stickies within a category to the top of the category list, show stickies at the top of search results or really do anything interesting with them without coding multiple loops into a page and splicing them back together - it gives me a headache even thinking about solving the resulting pagination issues.

    This is all because they are stored as a serialised string in the options table. If they were just another class of meta data in the meta table you could easily query against them to set result orders wherever you wanted to use them.

    Furthermore with this framework stickiness could easily be implemented as a scale, eg a stickiness value from 0 - 10. Theme developers could then use it for all kinds of custom sorts, ratings schemes could easily be hooked to stickiness etc etc

    Imagine how useful it would be to do something like:

    Posted: 9 years ago #
  2. Mark / t31os


    Sounds like a good idea to me, i assume you're referring to using the postmeta table.

    Rather then the term "Sticky Scale", i'd opt for "Sticky Priority"..

    Storing the sticky information in the meta table would make querying for sticky posts actually very easy, you'd then be able to do the following..

    query_posts( 'meta_key=_stickypost' );

    ..which assumes we'd use a preceding underscore to exclude it from meta function calls like the_meta()

    That also means meta_compare could be used to query for stickies with a certain priority ...

    query_posts( array(
    	'meta_key' => '_sticky',
    	'meta_compare' => '>',
    	'meta_value' => 1,
    	'orderby' => 'meta_value',
    	'order' => 'desc'

    ..which would then provide all stickies with a priority higher than 1, descending.

    Assuming the meta_value stored on save is used as a "Scale/Priority" value ...

    I hope i didn't misunderstand your idea... ;) I can see lots of possibilities for this idea.

    Posted: 9 years ago #
  3. zviedris


    When this idea could be implemented?

    It is great if you have more than one sticky post all the time as you can easily rearrange using priorities.

    Posted: 8 years ago #
  4. Ian Dunn


    I agree. It doesn't make any sense to store data about a post in an option field, rather than in postmeta. If it were just a meta field then querying for them would be consistent with everything else; as it is we have to do lame things like this.

    Posted: 7 years ago #
  5. gab.ro


    Yeah, it would really help to implement this. It makes much more sense than how things are right now.

    Posted: 7 years ago #
  6. Ryann Micua

    How much impact to performance will moving sticky posts from options field to postmeta table have?

    Oh and here's a new sticky post plugin that "floats" stickies to the top of category list http://wordpress.org/extend/plugins/sticky-posts-in-category/

    Posted: 7 years ago #

RSS feed for this topic


You must log in to post.

  • Rating

    12 Votes
  • Status

    This idea is under consideration