Site icon Hip-Hop Website Design and Development

Update Post metafield of specific categories

I have some meta fields in WordPress created by theme and i want to update it by using php.

The metafield stores url and i want to add some string after current url in custom meta.

i tried these method
Assign/update the custom field value for all posts

and made changes

'post_category' => array(14,16,19);

to select a particular category but it edited all posts of all categories.

and used this method to change meta field but it removed url and changet field.

$dealcode = "&deal_code=coupon";
    $urlvalue = get_post_meta( $post->ID, 'metakey', false);
    $urlvalue = $urlvalue . $dealcode;
    update_post_meta( $post->ID, 'metakey', $urlvalue );

please can anyone fix this.
Thanks.