WordPress.org

Support

Support » Plugins and Hacks » Get Custom Field Values » [Plugin: Get Custom Field Values] order of list

[Plugin: Get Custom Field Values] order of list

  • Hi. Does anyone happen to know how the “c2c_get_current_custom” orders the information? I have a number of “Team Members” custom field in each post that the plugin grabs and it does it correctly, but not in any order that I can discern. It isn’t alphabetical, nor is it in the order that I entered the data. So how is it doing it? And the ‘order’ function only works for the ‘c2c_get_recent’. Any help in the right direction would be nice.

    http://wordpress.org/extend/plugins/get-custom-field-values/

Viewing 2 replies - 1 through 2 (of 2 total)
  • No one knows? I just need to know if I can control the order that the plugin is grabbing multiple pieces of data from one custom field. Thanks.

    Plugin Author Scott Reilly

    @coffee2code

    WordPress & Plugin Developer

    The function c2c_get_current_custom() relies on WordPress’s get_post_custom_values() function. The latter performs a query without specifying an ORDER BY clause in the SQL, so the order of the data returned cannot be depended on (as you’ve noticed).

    Presumably you’d expect/prefer the custom field values to be ordered alphabetically?

    In thinking about it, it seems like it may be worthwhile for me to allow specifying an ‘order’ argument to a few of the functions. In the meantime, there isn’t a straightforward solution for you. Depending on where and how you’re using the function, you can invoke the output formatting function directly with the sorted custom field values.

    For example, Instead of something like this:

    echo c2c_get_current_custom( 'myfield', '', '', '', ', ' );

    You’d do:

    $cfvalues =  (array) get_post_custom_values( 'myfield', get_the_ID() );
    sort( $cfvalues );
    echo c2c__format_custom( 'myfield', $cfvalues, '', '', '', ', ' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Get Custom Field Values] order of list’ is closed to new replies.
Skip to toolbar