WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My company had a website developed that is entirely driven by custom fields. We're now discovering that we didn't anticipate the need for pages with custom layouts, the kinds that can be made on case by case basis in the visual editor. I have access to the site's page templates, but they all reference the custom fields. When I strip out the custom fields in a template, it doesn't retrive the content I entered in the visual editor.

I'm sure i'm missing something fundamental, but i'm not making any progress.

Example of one template:

Template Name: News & Events POST


 .nav1 li#menu-item-138 a{color: #F15C25;font-weight: bold;}

<div class="contents">

                <div class="left_bar1">
                <?php wp_nav_menu( array( 'container' => false, 'menu' => 'left_news'  , 'menu_id' =>'nav',  ) ); ?>

          <div class="year_box">

                <div class="box1">
                <?php $box1=get_post_custom_values('box1'); echo $box1[0];?>    

                <div class="box2">
        <?php $box2=get_post_custom_values('box2'); echo $box2[0];?>    

                <div class="box3">
        <?php $box3=get_post_custom_values('box3'); echo $box3[0];?>


            <div class="clear"></div>

<?php get_footer();?>
share|improve this question
What is your current template/custom field code? What have you tried? What worked? What didn't work? – Chip Bennett Feb 21 '13 at 20:28
I've tried leaving in the div's that block off areas of the page, eg: header, footer, content, sidebar, but stripping out the sections that bring in the content from the custom fields. When I create a 'blank template' that has all of the areas on the page, but with the custom field references stripped out, it results in a blank content area, even though i've entered content in the visual editor. – MMC Feb 21 '13 at 21:33
Nothing has worked so far. I'm trying to enter an example of a typical custom field driven page, and a page template based off of it that I modified, but the there's too many characters in the file to include it here. – MMC Feb 21 '13 at 21:36
Please post your actual custom page template code in your question. – Chip Bennett Feb 21 '13 at 22:50
Fixed... code needs to be marked as code, using the "code" button in the editor. – Chip Bennett Feb 22 '13 at 19:16

Use advanced custom field plugin download here

You can easily map custom field groups to set of pages, posts , post types, taxonomies etc.

share|improve this answer
I figured it out, and it was something fundamental. I replaced all of the div tags that referenced box3/custom fields with references to the loop: <?php if(have_posts()):?><?php while(have_posts()):the_post();?> <?php the_content();?> <?php endwhile;?> <?php endif;?> – MMC Feb 22 '13 at 20:16

I figured it out, and it was something fundamental. I replaced all of the div tags that referenced box3/custom fields with references to the loop, this worked:

                    <?php endwhile;?>
                    <?php endif;?>
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.