Why is WP_Query not displaying expected data?

You must change your date to an ordering like @ Krzysiek Dróżdż said or use meta_type options. I have tested with the string version. An example of meta_type $args is listed below. See also MySQL time variants /* Plugin Name: Meta Filter Plugin URI: https://wordpress.stackexchange.com/questions/304333 */ // ?XDEBUG_SESSION_START=304333 function wpse_304333() { echo ‘<p>wpse_304333</p>’; $args = … Read more

How to get correct value from checked()?

The purpose of checked() is to output a checked=”checked” attribute based on a current value. By using it the way you’re using it there you’re forcing Si to never be checked and No to always be checked. So what you want to do is use both arguments of checked() to compare the value of the … Read more

wp_query get data from advanced custom field in wordpress

ACF plugin stores data in the wp_postmeta like the default WordPress custom fields. To get data from a custom field your code should look like this (assuming the custom field name is “brand_name”). $title = get_the_title(); $the_query = new WP_Query( array( ‘posts_per_page’=>9, ‘post_type’=>’product_name’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( “key” => “brand_name”, “value” => … Read more

Ajax is not working in a loop

Your code has var getid = $(‘#my-categorychecklist input:checked’).last().val(); see the .last(), that’s why you’re only getting the last item Also, why do you have the same thing in getid and matchid? You need to store the selected categories in an array and loop through them, try something like: var selected_cats = $(‘#my-categorychecklist input:checked’).map(function() { return … Read more

Get image url using image id

You can use REST API to retrieve media item. Just send GET request to this address (change example.com to your site): http://example.com/wp-json/wp/v2/media/<id> If you pass correct ID, then you’ll get all info regarding that media file. For example I get something like this for one of my image files: { “id”: 546, “date”: “2019-01-23T11:22:15”, “date_gmt”: … Read more

Specifying meta field’s column type in Database using add_post_meta

When you use add_post_meta, no column in database is created. All post meta data is stored in wp_postmeta table (https://codex.wordpress.org/Database_Description#Table:_wp_postmeta). Here’s the structure of that table: post_id is the ID of post that this meta data is assigned to meta_key is the key of meta (in your case favourite_fruit_code) meta_value is the value of that … Read more

Create custom post with meta field with AJAX and the WordPress REST API

I haven’t tested your code, but here the $object is an object and not array: // Here, $object is a WP_Post object. function slug_update_post_meta_cb( $value, $object, $field_name ) { return update_post_meta( $object->ID, $field_name, $value ); } And you can actually use register_meta() with a custom post type: register_meta( ‘post’, ‘myfield’, [ ‘object_subtype’ => ‘custom_type’, // … Read more