1

If you want to use that function everywhere, you need to be sure that: $current_user is always defined as a WP_User object, $current_user->ID is different from 0 (zero) - only for logged in users, jQuery select2() function (plugin) exist, avoiding JS errors on some other pages (where Select 2 is not enabled). See: How can I check if a jQuery plugin is ...


1

There are some errors as get_post_meta() first argument need to be a defined product ID here (and in your code post_ID is not even dynamic variable and will not give anything)… Try the following: <?php function check_gtin(){ if ( $gtin = get_post_meta(get_the_id(), 'gtin', true) ){ echo "gtin13:". $gtin; } else { ...


Only top voted, non community-wiki answers of a minimum length are eligible