WordPress.org

Ready to get started?Download WordPress

Forums

Get Custom Field Values
Code and Widget Don't Sort Correctly After 4 Custom Field Val (3 posts)

  1. flahammerhead
    Member
    Posted 2 years ago #

    The widget and code seem to “break” after 4 key/value additions to custom fields. I have created a custom field called “sponsorship” where I track sponsors. When I add more than four values to a post (using custom field sponsor), the sorting breaks and the most recent value does not appear on top. I am using the '<?php echo c2c_get_current_custom( $field='sponsorship', $before='My Most Recent Sponsor: '); ?>' in the loop.

    Is this a limitation or am I doing something wrong? Thanks

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

  2. flahammerhead
    Member
    Posted 2 years ago #

    Additional Information from above:

    I am trying to use this plugin to track sponsors via a custom field. The key is called 'sponsor' and the value reflects their name and the date of their sponsor. I simply want the values of this custom field key returned in the order they were entered over time for a given post. The array that is created over time shows a different order than that actually entered over time. Can I apply a sort using the database unique ID? Can I sort simply in the order they were entered? Thanks

  3. Scott Reilly
    WordPress & Plugin Dev
    Plugin Author

    Posted 2 years ago #

    The custom fields should be listed in the order you defined them. It's a little unclear based on what you've specified above how you have things set up. Have you defined multiple sponsors in a single custom field, or are you using multiple custom fields? You've also indicated the key is named either 'sponsorship' or 'sponsor'. You made mention of the widget, but you provided an example using the template tag.

    I'm going to assume you are using the key 'sponsorship' and that you are defining multiple custom fields of that key for a single post, one for each sponsor.

    In that case, you'd want to use the following snippet:

    <?php echo c2c_get_custom( 'sponsorship', 'My Most Recent Sponsors:', '', '', ', ' ); ?>

    You example code won't list more than one at a time, since the plugin by default only lists one. You have to define the argument that indicates what to put between items in order to list multiple items. My snippet simply puts a comma and space between each listed sponsor.

    If I've misunderstood what you're trying to do, please clarify.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic