Posted By

mesh606 on 08/23/11


Tagged

wordpress


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Kurt


better wordpress custom fields


 / Published in: PHP
 

declare all custom fields first

  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  

You need to login to post a comment.