The best way to go about this is with $wpdb
. The query to draw out meta_value by category is:
$query = $wpdb->get_results(
"SELECT p.`ID`, pm.`meta_value` FROM {$wpdb->postmeta} pm
LEFT JOIN {$wpdb->posts} `p` ON `p`.`ID` = pm.`post_id`
LEFT JOIN {$wpdb->term_relationships} `tr` ON `p`.`ID` = `tr`.`object_id`
LEFT JOIN {$wpdb->term_taxonomy} `tt` ON `tr`.`term_taxonomy_id` = `tt`.`term_taxonomy_id`
WHERE `pm`.`meta_key` = 'adhesion_box'
AND `p`.`post_status` = 'publish'
AND `p`.`post_type` = 'post'
AND `tt`.`taxonomy` = 'category'
AND `tt`.`term_id` = $cat
");
Related Posts:
- JSON parsing error syntax error unexpected end of input
- Jquery Ajax Posting JSON to webservice
- TypeError: $.ajax(…) is not a function?
- Can’t get a JSON object in response to an Ajax request with wp_ajax
- AJAX returns response 0
- How to Use JSON With AJAX?
- Cannot access elements of json object
- How to get those data using with ajax json?
- Intergrating agile carousel to wordpress: how to write the ajax_callback function
- delete post meta by AJAX
- How to retrieve WP_Object that is inside an array of another array
- Can’t add classes using jQuery from a JSON string with get_body_class()
- jQuery AJAX add json2 dependency?
- data.map is not a function
- My javascript is returning this error: $.ajax is not a function
- XML Parsing Error: not well-formed in FireFox but good in Chrome
- Ajax Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource
- jQuery posting JSON
- How to get a cross-origin resource sharing (CORS) post request working
- SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
- jQuery Form Validation before Ajax submit
- $(document).ready(function() is not working
- ajax stopped working when not logged in?
- Using jQuery to delete data stored in wp_options
- How to get the path to current theme, but from a JS file?
- WordPress Ajax URL for function in functions.php
- Ajax call does not activate callback function
- AJAX call returns 0
- AJAX function returning -1
- jQuery and AJAX Not working with Select Form Element
- How to reload a select box of posts dynamically?
- How to pass both action and formdata in wordpress ajax?
- jQuery AJAX form validation
- Proper way to load a single post via Ajax?
- Basic WordPress AJAX Call
- Add X meta box inputs based on form at top of meta box, how to do it right?
- Trying to get single posts to load on the front page via ajax
- Bind to WPSetAsThumbnail
- Ajax not firing properly using Firefox, but works in Chrome
- Disable collapse of admin meta boxes
- Script dependencies for post.js
- How to load whole WordPress pages dynamically with AJAX/jQuery like this following website?
- Creating custom AJAX requests
- How to pass jQuery ajax URL value
- Basic ajax call in WordPress
- how to get the comment ID in the front end when the REPLY button is clicked?
- Admin wp_ajax hook returning 0
- wp_ajax unauthenticated and authenticated
- WordPress ajax function parameter value not being passed
- WordPress customizer refresh screen after save
- Is there a restriction in WP on the use of jQuery load function?
- JSON output returns page source code [closed]
- Display data on same page as form without refresh
- Hide metabox dependant on page template chosen
- Ajaxify calendar
- Error when posting comment form: The error is TypeError: e[h] is not a function
- How to Dynamically Load Content Into Body of Bootstrap Modal Window?
- I want to import my Json file into a custom made display-modal. How do i link my Json file?
- Frontend Post with JQuery AJAX to Php Issue
- Passing a varible from jQuery to PHP
- Add/remove action on jQuery toggle
- Retrieve post info within AJAX helper function
- url – ajax loaded but no JS
- merge wp rest api query to get posts per category does not work
- Ajax form submit not working, returns 0
- Adding URL of PDF from Thickbox in a Meta Box
- how to json_encode(); the Loop content so that the encoded array is [“0”:content, “1”:content]
- No Object Properties sending form through AJAX
- Redirect wp_dropdown_pages() to an AJax request?
- click event to unhide something after ajax not firing
- WordPress Insert not working with ajax
- Search query with Ajax
- WP AJAX API with JS file
- how to use wp_editor() here am getting empty result
- admin ajax php success returns 0
- Parse wordpress blog data using json api and ajax
- Is there some jQuery conflict here?
- Getting jQuery AJAX to work in WordPress (getting -1)
- problems with jquery external rss feed integration
- AJAX calendar navigation returns -1
- Which hook to use when adding ajax to viewer-facing side?
- my example with ajax doesn’t work
- Loop through WordPress API response errors
- How to inject data content from external json into a modal, using UIkit?
- Get ajaxForm response value
- Collect custom post in a calendar
- Autocomplete for titles via ajax – rework of past post away from like_escape()
- how to remove/exclude html coding from json file while export?
- Retrieve customizer value using ajax or customizer api and print the value in theme
- owl carousel not working after ajax load [duplicate]
- WordPress version for this autocomplete jQuery code
- Ajax Request with jQuery not happening
- JQuery multiple toggle values
- How to pass more information though separate post keys via AJAX
- Loop not appending through infinite-scroll ajax call
- Contact Form 7 submission does not complete [closed]
- Using WP Ajax and jQuery to process multiple forms on the same page?
- Combo box populating a DIV using ajax/jquery
- Load loop images on click / defer image loading until click or other event
- Widget won’t work due to old JavaScript? Any ideas how to make it work? [closed]