0

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:

<?php
/*
Template Name: News & Events POST
*/

 get_header();?>



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



<div class="contents">

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

          <div class="year_box">

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

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

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

           </div>


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

<?php get_footer();?>
5
  • 2
    What is your current template/custom field code? What have you tried? What worked? What didn't work? Commented Feb 21, 2013 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.
    – MMSI
    Commented Feb 21, 2013 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.
    – MMSI
    Commented Feb 21, 2013 at 21:36
  • Please post your actual custom page template code in your question. Commented Feb 21, 2013 at 22:50
  • Fixed... code needs to be marked as code, using the "code" button in the editor. Commented Feb 22, 2013 at 19:16

2 Answers 2

0

Use advanced custom field plugin download here

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

1
  • 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;?>
    – MMSI
    Commented Feb 22, 2013 at 20:16
0

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;?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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