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
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- How to get custom post meta using REST API
- Using get_post_meta with new_to_publish
- Add custom fields to search
- Meta Query with AND & OR?
- Can I count the number of users matching a value in a multiple value key?
- WP doesn’t show Array Custom Fields?
- How do I search an array stored in a custom-field using WP_Query?
- get_pages sort alphabetically by meta value
- Get updated meta data after save_post hook
- Compare meta_query decimals not working right
- WordPress altering my custom query, How to fix it?
- How to break meta values into different items and avoid duplicates?
- ajax delete value from custom field array
- How can I sort get_users() by any value (last_name, user defined fields and more)
- How can I query on the year part of a complete date in a custom field?
- Transition from (classical) serialized custom meta field to (gutenberg) rest enabled meta
- Unable to show ACF’s Image Custom Field properly in Genesis Framework [closed]
- Author Page Custom Query WHERE author OR [post meta value] OR [post meta value]
- What Is meta_id In wp_postmeta?
- How to display Meta Field Value?
- How do I use wp_query for WordPress search?
- Nav Menu – Add class based on meta keys
- Orderby custom field meta value ASC and then by date DESC
- Sorting posts ordered by custom field value
- Unique Post Meta Values
- Create an Array of Specific Custom Post Meta
- WP 3.1 meta_query for multiple custom field values
- Remove Body Classes
- How to create a shortcode to print specific values stored in a post meta array?
- Get posts with same meta value as current post
- Add custom field to all posts in specific post_type
- Change the sort order for posts to include custom field
- Button inside Custom Meta Box triggering the Update Button
- How to load an assets based on custom field value?
- How can you include custom post meta in search without calling each key?
- Get Data From wp_sitemeta for Multisite network
- How can I do a variable for meta_query?
- Can I access a post meta field before the loop?
- wrap text around custom fields array
- Get all the posts where meta field with multiple choice has several values checked
- Hide custom fields when empty
- Save all the post tags inside a custom field
- ACF: How to get users with a ACF flexible content subfield with a specific value AND layout?
- WordPress loop by meta key that is an array? and how loop multiple arrays
- How add multiple wp_editor_box to new post
- Update post meta custom field using block editor
- Get YouTube video id from url in a custom field
- Related query shows same image in loop
- Can’t Output get_post_meta?
- put saved metabox values back into fields and then display on the front end
- Displaying an ACF list of users
- Meta value Array
- How to get custom image field of specific post id
- Custom field to array?
- How to sort by custom field value?
- Custom field outside the loop and inside an array
- get_post_custom_values problem, please help
- get posts based on non-single metadata
- How do i create a custom post query when the meta value is an array?
- Woocommerce products search with custom fields
- Custom meta fields and meta keys
- How to save multiple values with same meta_key, each value linked to another tag id
- Saving Custom Field that includes Quotation marks
- searching by keywords in post’s metas or pagination links problem
- update meta field value after
- meta_query ‘compare’ => ‘!=’ not working
- Query Posts based on custom field value
- Create custom query for search?
- Display Data From This Custom Media Upload Meta Box?
- Sort custom fields in admin by last field added
- Save values generated via API as custom meta fields
- Hard Define Custom Field Value
- Adding custom field to an array