Get custom fields without _edit_last, _edit_lock, _wp_page_template and _visual-subtitle

1k Views Asked by At

I'm getting custom fields using

<?php $meta = get_post_custom($level_2->ID); ?> <?php foreach ( $meta as $key => $value) { ?> <?php echo $key.': '.$value[0].'<br />'; ?> <?php } ?>

and it is showing

_edit_last: 1<br> _edit_lock: 1483226440:1<br> _wp_page_template: page-services.php<br> Body Repair: ValueBodyRepair<br> _visual-subtitle: <br>

I need only 4th row Body Repair: ValueBodyRepair<br>

1

There are 1 best solutions below

1
On BEST ANSWER

If you would adjust the code this way, you would get only the one you need:

<?php $meta = get_post_custom($level_2->ID); ?>
<?php foreach ( $meta as $key => $value) { ?>
  <?php if(substr($key, 0, 1) !== '_'): ?>
    <?php echo $key.': '.$value[0].'<br />'; ?>
  <?php endif; ?>
<?php } ?>