Wordpress if custom field else


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. $number = get_post_meta($post->ID, 'number', true);
  3. if ( $number ) {
  4. echo 'there is a custom field value';
  5. }
  6. else {
  7. echo 'no custom field value';
  8. }
  9. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.