Answer Version 2
I apologize for the confusion.
Here’s how you can use the usort()
function to sort the images (in the div#pic-con
on the front-end):
<div id="pic-con">
<?php
if (!empty($vid_pix)) {
usort( $vid_pix, function( $a, $b ){
$aPor = (int) get_post_meta( $a, 'photo_order', true );
$bPor = (int) get_post_meta( $b, 'photo_order', true );
if ( $aPor === $bPor ) {
return 0;
}
return ( $aPor < $bPor ) ? -1 : 1;
} );
foreach ($vid_pix as $vP) {
// echo `div.photo-upload-box` here
}
}
?>
</div>
Related Posts:
- Orderby meta_value only returns posts that have existing meta_key
- ORDER BY custom field value
- Can I query custom meta data through WP_Query
- When using add_post_meta and update_post_meta, is there any way to give the individual arrays keys?
- Auto sort the wp-admin post list by a meta key
- Is it possible to store arrays in a custom field?
- Ordering posts by anniversary using only day and month
- Displaying posts with only upcoming dates according their custom field date value
- Sorting posts by multiple values, combined
- Which is best in the following scenario : post_meta vs custom table vs parent/child posts
- Get specific custom field keys from a post and put into an array
- How to add a new meta key and assign timestamp to posts
- Run a check for multiple meta key values
- How do I have WP_Query match posts based on search parameter OR meta fields? (rather than search parameters AND meta fields)?
- Sort alphabetically by custom field
- Ordering posts by custom field named “date” in backend
- Unique meta_key with array value vs repeated meta_key with single values
- Avoiding ACF get_field and returning to core WordPress function
- ORDER BY custom field value out of where clause
- wordpress custom loop ascending descending posts by custom field
- How to improve my non-unique metadata MySQL entries?
- Trouble with serialized metadata
- How do i output images from URL’s added to the same custom field key
- Build Array from Input Fields question
- Order by a meta field in query loop
- WP Query Args – search by meta_key or title
- SQL query based on two different custom field values
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Difference between meta keys with _ and without _ [duplicate]
- What is the index [0] for on post meta fields?
- Using meta_query, how can i filter by a custom field and order by another one?
- What is “meta_input” parameter in wp_insert_post() used for?
- How to enable revisions for post meta data?
- The “_encloseme” Meta-Key Conundrum
- Best way to programmatically remove a category/term from a post
- Using get_post_meta with new_to_publish
- Add custom fields to search
- SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999
- Matching Serialized Arrays with meta_query
- Custom field metabox not showing in back-end
- Meta Query with AND & OR?
- So much data in postmeta
- Can I count the number of users matching a value in a multiple value key?
- Getting attachments by meta value
- How to hide meta box values from custom fields list?
- WP doesn’t show Array Custom Fields?
- get_post_meta() unserialize issue – returns boolean(false)
- What is the advantage of the wp_options design pattern?
- Storing meta fields multiple times OR once with multi dimensional array?
- Allow user to create instances of custom field
- display specific custom fields
- How do I search an array stored in a custom-field using WP_Query?
- How Can I save multiple records in same meta key?
- Is there a hook / action that is triggered when adding or removing a post thumbnail?
- get_pages sort alphabetically by meta value
- Meta keywords and descriptions plugin for manually editing meta for each page/post
- passing argument to get_template_part() or a better way to code
- Archive sorting functions by custom fields (front-end)
- Get updated meta data after save_post hook
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- Save HTML formatted data to post meta using add_post_meta()
- Trying to perform complex custom field query with order by set to field value
- importing data from non-wordpress mysql db
- How to update single value in multi dimensional Post Meta?
- Is there a way to do multiple ordering on a multiple meta_query?
- Order by custom field date?
- Create meta boxes that don’t show in custom fields
- Transients vs CRON +Custom Fields: Caching Data Per Post
- Unable to save datetime custom meta field using update_post_meta() function
- Up/Down voting system for WordPress
- post meta data clearing on autosave
- WordPress Search Custom Meta Field Only
- Create custom field on post draft or publish?
- Display info from custom fields in all images’ HTML
- Compare meta_query decimals not working right
- WordPress altering my custom query, How to fix it?
- WP Meta Query for some meta (array) values
- Calling Specific Pages with wp query Part II
- Loop through two different sets of custom fields
- get_post_meta fields don’t show up on posts page
- Update meta values with AJAX
- How to break meta values into different items and avoid duplicates?
- use get_posts to get custom field data, but in one array
- copy attachments to another post type and change attachment url
- Cannot edit post meta fields with rest API
- ajax delete value from custom field array
- Save attachment custom fields on front end
- How can I sort get_users() by any value (last_name, user defined fields and more)
- Slow meta query with multi meta keys
- How to use pagination with get_post_meta
- Copying Custom Meta Values from existing post to a duplicate post
- Using OR in WP_Query negates the “NOT EXISTS” compare
- Add a post meta key and value only if it does not exist on the post
- How can I query on the year part of a complete date in a custom field?
- Saving an array in a single custom field
- Move value of one custom field to another