Posted By

paul0078 on 04/15/12


Tagged

wordpress custom-field


Versions (?)

Function to get custom field data


 / Published in: PHP
 

  1. // place following function inside functions.php
  2. function get_custom_field_value($szKey, $bPrint = false) {
  3. global $post;
  4. $szValue = get_post_meta($post->ID, $szKey, true);
  5. if ( $bPrint == false ) return $szValue; else echo $szValue;
  6. }
  7.  
  8. // use following code to call function after checking that it exists
  9. <?php if ( function_exists('get_custom_field_value') ){
  10. get_custom_field_value('home heading', true);
  11. } ?>
  12.  

Report this snippet  

You need to login to post a comment.