Define Function in functions.php or plugin and call in theme loop

Try use this (functions.php) :

function product_title($id) {
  $custom='CustomField'; // Your custom field here
  return get_post_meta($id, $custom, true);
}

and call func in your template (in loop and etc…):

<?php $p_title=product_title(get_the_ID()); ?>
<h3>Product : <?php echo ($P_title); ?> </h3>

Leave a Comment