Hope you people are doing good today. :)
i used add_post_meta() and update_post_meta() in function but neither add_post_meta() function working nor update_post_meta.
Here is code.
$post_id = $_POST['post_id'];
add_post_meta($post_id, 'counter_meta', 'Dani');
$return = get_post_meta($post_id, 'counter_meta', true );
echo '<pre>';
print_r($return);
exit;
it's return nothing :(
I checked before id is coming in post_id
variable.
Any help.?
Use
$post_id = $post->ID;
add_post_meta($post_id, 'counter_meta', 'Dani');
$return = get_post_meta($post_id, 'counter_meta', true );
echo '<pre>';
print_r($return);
exit;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.