You would have to JOIN
a couple of tables.
SELECT meta_value FROM wp_postmeta as pm
INNER JOIN wp_term_relationships as tr ON (pm.post_id = tr.object_id)
INNER JOIN wp_term_taxonomy as tt ON (tr.term_taxonomy_id = tt.term_taxonomy_id)
WHERE 1
AND tt.taxonomy = 'laptop'
AND pm.meta_key = 'quantity'
I am fairly sure that is right. These things are complicated.
If your meta_value
is a number– that is, no punctuation or other spaces– you should be able to use SUM(meta_value)
and avoid the array_sum
after the fact.
Related Posts:
- Custom field values to taxonomy terms
- Woocommerce Custom Meta Boxes- How to only display if they actually have content
- ACF – Can’t get custom post type by taxonomy
- I want to show image from custom field image on my custom page template
- How do I organize posts based on their taxonomy?
- How can I create a list of page titles from custom meta values?
- Create a hierarchical taxonomy list in WordPress
- Randomly Assign an Image’s Alt Text Based on Data From Post
- Passing the custom field values in the wp_get_current_user array function
- Sort posts by custom fields value using dropdown menu
- Can I prevent the user from adding more than two levels deep of terms inside of a taxonomy metabox?
- Custom profile field with birthday. Troubles with
- Conditional display for custom fields/taxonomy
- WordPress – Display array data of a child
- Why my filterable portfolio page work not perfectly between slug button and slug output WORDRPESS?
- wordpress allow user to edit user profile with custom fields
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- Grab posts by multiple categories
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Need Help Fixing My Iframes [closed]
- Firing schema via code in functions.php doesn’t work
- How to get original custom taxonomy slug after the slug has been rewritten?
- Adding number to date not working [closed]
- How can I add extra word in permalink when someone click download button?
- Saving and Restoring a Canvas on A Individual User Basis
- Displaying custom taxonomy on WooCommerce product page
- Seach custom post type posts only by meta fields?
- How to use thumbnail size of image if I’m only using src to get image
- 3 Slashes appear after Apostrophe in custom fields after updating product-site
- How to split links generated into an xml sitemap to avoid exceeding 30 sec maximum execution time?
- how to retrieve a value if a checkbox is checked
- Trouble checking if custom woocommerce checkout field is empty or not
- Two queries for a WP_User_Query search work perfectly apart, but not together
- How to get post’s current parent term ID?
- auto-populating custom nav with all items from custom post type
- multiple taxonomy select display only one in front end
- Display parent and child taxonomies in separate drop down select fields
- Add / Update Custom Fields After Select Pictures in Media Window
- conditional logic for front-end custom field edits
- How to show only subcategories in parent category not parent category?
- Trying to retrieve post meta
- need help with existing code showing subpages
- Automatic Shortcode Creation with Custom Fields [closed]
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- How to add specific meta tags to head of cart and checkout pages in woocommerce?
- Pull Tags But Not as Links
- Custom Field IF/ELSE PHP
- Which PHP page is the Default Posts Page
- How to combine 2 php functions into one function with a custom field
- Remove the last X characters of a custom field value
- Advanced Custom Fields – display label and value only if value entered
- Is it possible to retrieve all posts with a certain value for metadata?
- Saving zero in meta box
- Non-Closing PHP Query in WordPress Loop
- Find a way to retrive data updated through metabox plugin to web page
- Why are the details of my todo not saving?
- How to check if a PHP string is different than meta field?
- Can’t save php string to a custom field
- Copy taxonomy terms from one post to another programmatically
- Display custom field on 404 page outside loop
- Why does this update_post_meta function not delete the custom field itself?
- How to show/hide php table rows based on the content of custom fields
- Run str_replace on title and save the output to a custom field
- Only show image from custom field when present
- working with term_relationships table
- how to get serialized post meta
- Hide Heading if ACF Field is empty
- How to filter custom taxonomy term name, slug, and description?
- Custom meta box values are not getting saved for my custom post type
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Ajax filter button display all posts
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Hierarchical taxonomy list with modificated term links
- Use get() method to grab all categories and output inside another method
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- WordPress loop by meta key that is an array? and how loop multiple arrays
- if custom field doesn’t exist, use post thumbnail instead, as image background
- Show the section only if custom taxonomy was chosen
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- How to store multiple custom meta box
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- Listing titles and custom fields of entries within subcategories
- fetch woocommerce product with custom taxonomy
- Handling repeater data
- How to add data to a custom field at the wp_users table?
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Concatenate Custom Field Value & HTML Value
- Output custom text field as unordered list
- Conditional featured image with youtube thumbnail
- Create a a form for custom taxonomy terms
- `update_post_meta` not working anymore
- Order a WP_Query by meta value where the value is an array
- Storing content into a custom taxonomy
- Unable to render custom field after attempt to generate a list of recent post in page template
- Add a custom class to the body tag using custom fields