Get all of the post ids from the specific post type, loop through them and simply add the custom fields together and display the sum below the post type title on edit.php (Notice the add_filter first parameter, you need to change the products part to your post type name)
add_filter('views_edit-products','products_price_sum');
function products_price_sum($views) {
$args = array(
'post_type' => 'products',
'posts_per_page' => -1,
'post_status' => 'any',
'fields' => 'ids'
);
$postslist = get_posts( $args );
$sum_total = 0;
foreach ($postslist as $post) {
$price = get_post_meta( $post, 'price', true );
$sum_total = $sum_total+$price;
}
//This is the sum of the price field
$views['price_sum'] = '<strong>Price Sum:</strong> '.$sum_total;
return $views;
}
Related Posts:
- How to Add Custom Fields to a Custom Post Type?
- Do_Shortcode not working for Embed
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- Custom Taxonomy Template Post List with Sort Order
- Display Custom Post Type Fields
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- add_meta_box: Datepicker like the one for postdate?
- Custom field losing p tags on display
- Using posts and postmeta table to store custom Address Book Plugin data
- Bulk edit custom excerpt text in WordPress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Getting a “Changes you made will be lost” dialog prompt on a custom post type page
- Frontend posting – everything saves other than checkboxes?
- Search Custom Post Type Custom Fields
- Saving repeated option values in a custom query
- Query Custom Post Types by date (custom field) range
- Automatically populate a hierarchical taxonomy from a custom field
- handling csv data with a custom post type
- How to remove slug metabox from custom post type’s page?
- Custom fields in Permalinks?
- query posts and custom post type with meta key
- Dynamically add / duplicate custom meta in custom post types
- Problem fields custom date, time, and checkbox
- Custom Post type and Custom Field WP_Query
- Adding Show Less/More link to Custom Post Meta
- Sorting custom post type columns with external data and without meta values
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- WordPress Custom Fields Won’t Save
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Meta Query Not Returning Output Despite Having Matching Values
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- First custom field value (out of several) displayed twice after query
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- filter search custom field query
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- Warning: Invalid argument supplied for foreach() [closed]
- Add additional field to custom post_type
- Sorting posts by custom field value in array
- How to conditionally add Custom Post Type to Front Page
- Custome fields not displayed
- Displaying custom fields for custom post type generate with Custom Post Type UI Plugin
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Custom post type name and assigning custom taxonomy
- Custom post types, disable fields
- Variable Products as custom post types
- Best way to create a search for custom post type by custom field values
- Building a Portfolio and need some direction
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- Display Posts Query with IF function
- Excerpt length: get first paragraph
- Custom PT, Taxonomys and wordpress query
- Confusion about how to use Custom Post Types, Custom Taxonomy or Category?
- How can i loop through custom post type according to custom meta field?
- How to use get_post_custom_values to return the value of an array
- Problem with date comparison for custom fields
- CMS – User confusion when creating new page and having to select template and save first to see correct fields
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Creating a custom page post type just like the original “pages” post type using CPT UI
- Using OR relation in meta_query to check for a value before sorting by another
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- Sort custom post archives by a meta value from a different custom post type?
- Displaying posts inside table having issues
- Ordering Post by Meta Key (Not Working)
- Error when moving custom post type to bin
- Enforce all custom posts have specific custom fields
- Use WP Title instead of custom field to call
- Custom taxonomy template for custom fields loop [closed]
- Add more custom fields when creating a new custom post type
- How do I display specific custom posts, and how do I edit a post’s singular page?
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- What’s the most efficient way to get two queries based on an if statement?
- Retrieving custom post type fields without a post
- Amend posts using wp_insert_post
- Custom Fields as Post Type Options
- pre_get_posts with multiple post types AND a meta_key
- How to get past and upcoming post by defining date in custom field?
- Selecting posts older than the current Unix epoch timestamp
- display some fields in custom post backend
- Select Menu for Custom post Type does not save
- loop through custom post-type with two meta_keys
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Send email on creation of custom post type and use get_post_meta()
- pre_get_posts causes Custom Posts appear under ‘Pages’ menu
- Post object GUID adding http:/
- WordPress does not show the custom fields box
- Query order by a numeric ACF field