Remove the last X characters of a custom field value

You have to consider that you’re dealing with substr() a string related function as the str in the function name indicates. That does mean that the parameter $string you give actually has to be of the type string.

get_post_meta() on the other hand does just give you back whatever type you saved in the first place. So it isn’t guaranteed that your getting back a string – you have to make sure of that yourself. Which you can do by type casting the value, variable you receive.

So far so good, let’s put it together:

$custom_field = (string) get_post_meta( $post->ID, "CUSTOMFIELD", true ); 
echo substr( $custom_field, 0, -3 );

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş