WP-API : post_meta not updated… but have another entry
I’ve answered my question… when your not giving the id of the post meta … it’s creating another one … you give the id and it’s updating… –
I’ve answered my question… when your not giving the id of the post meta … it’s creating another one … you give the id and it’s updating… –
First you have to declare the global $wpdb before using it. Also you need to include the table prefix when calling the table names. global $wpdb; $posts_table = $wpdb->prefix . “posts”; $posts_meta_table = $wpdb->prefix . “postmeta”; Next get an array of post ids by the author needed( make sure you have the id of desired … Read more
Check out this post under the “Get Posts Meta Field Is Not Available By Default” heading: https://1fix.io/blog/2015/07/20/query-vars-wp-api/
Try update_post_meta function without esc_attr <?php update_post_meta($post_id, ‘province’, $_POST[‘postProvince’], true); ?>
$Featured_image = $wpdb->get_results(” SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = ‘_thumbnail_id’ ORDER BY p.post_date DESC LIMIT 15 “,’ARRAY_A’); A related solution, to query for posts WITHOUT providing a post ID (ordered by post date, and using the wp_ database prefix): SELECT p1.*, … Read more
Please try below code and check if ‘sound_s‘ key exists in the array or not $file_id = get_post_meta($post_id); echo “<pre>”; print_r( $file_id ); exit;
I think you can do a left join : left join $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = ‘subscribe’) Where “subscribe” it’s the name of your custom field. So your code could be: $dayswithposts = $wpdb->get_results(“SELECT DISTINCT DAYOFMONTH(p.post_date) FROM $wpdb->posts as p LEFT JOIN $wpdb->postmeta my_field_meta on (p.ID = my_field_meta.post_id and my_field_meta.meta_key = … Read more
I did spot one problem in your case clause for radio buttons: In your <label> tag, you use $val, but I think you meant $option[‘id’]. I don’t see how it could be related to the foreach error you’re getting, but it won’t hurt to fix it. The odd thing is that the real error is … Read more
why not add a filed to user meta once they have voted and just check to see if that specific user can vote? add to your add vote function this lines: global $current_user; get_currentuserinfo(); add_user_meta( $current_user->ID , ‘voted’, true ); now if a user votes it saves a usermeta filed. then you can create a … Read more
get_post_meta() function works In and Outside of the loop and you saying that you do see it working on a single image “but doesn’t in loop” means that you probably did not add the code to the right loop. To be clear It works with all posts types.