WordPress.org

Ready to get started?Download WordPress

Ideas

Add order by meta_id to update_meta_cache

  1. donatien
    Member

    12345

    As of now get_post_meta returns value pairs in random order when used with multiple custom fields with the same key. It would be useful to either get the meta_id back for manual sorting or (better) having the result set returned ordered by meta_id which is the order they were entered.

    Ran into trouble when I tried to match up several "pairs" of custom fields with same keys and fixed it by changing line 294 of /wp-includes/meta.php to:

    $meta_list = $wpdb->get_results( $wpdb->prepare("SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list) order by meta_id", $meta_type), ARRAY_A );

    Simply added the "order by meta_id".

    It would be great to have this included in the core, since it's not likely to hurt anyone. Some order is better than randomness.

    Posted: 3 years ago #
  2. Justin Tadlock
    Member

    12345

    +1

    Have you added a ticket for this on Trac?
    http://core.trac.wordpress.org

    Posted: 3 years ago #
  3. donatien
    Member

    12345

    Nope, thought the right way to go about it was to post it here for consideration and then someone in the dev team would pick it up if it was a good idea..

    Should I put it in Trac?

    Posted: 3 years ago #
  4. Justin Tadlock
    Member

    12345

    Good ideas tend to gain more traction in Trac, especially if you already have code that could fix the problem.

    Posted: 3 years ago #

RSS feed for this topic

Reply

You must log in to post.

  • Rating

    12345
    6 Votes
  • Status

    This idea is under consideration