Last Updated: February 25, 2016
·
1.888K
· felipelavinz

WordPress: get_post_meta() returns results in random order

Quick and to the point:

  1. The function that queries meta-data doen't have an ORDER BY
  2. MyISAM tables change the order of data when updated
  3. Switch to InnoDB, so all queries without "ORDER BY" are sorted by primary key and your results will be always in the same order :-)

...btw, this bug is reported and should be fixed in WordPress 3.8

léelo en español en: http://www.yukei.net/2013/11/wordpress-get_post_meta-devuelve-resultados-en-orden-aleatorio/

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

PHP applications still send a browser full of JavaScript. Hardening the server does not inventory the payment, analytics, and plugin scripts that run after the HTML is delivered.

Security insights from Cside