better wordpress custom fields


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

declare all custom fields first


Copy this code and paste it in your HTML
  1. <?php global $post;
  2. $bg_img = get_post_meta($post->ID, 'bgimg', 1);
  3. $heading = get_post_meta($post->ID, 'mainheading', 1);?>
  4.  
  5. <div class="int-head-pic" style="background:url(<?php echo $bg_img; ?>) no-repeat;" >
  6. <h2 class="mainheading"><?php echo $heading; ?></h2>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.