Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm taking two templates and molding them into one that suits my needs. I'm getting this weird issue where things are repeating themselves just before the footer. Here's the code:

<?php get_header(); ?>

<?php if ( get_option('mycuisine_blog_style') == 'false' ) { ?>
    <?php if ( get_option('mycuisine_quote') == 'on' ) { ?>
        <div id="quote">
            <div class="container">
                <div id="quote-shadow"></div>
                <p id="quote-line-1"><?php echo get_option('mycuisine_quote_line1'); ?></p>
                <p id="quote-line-2"><?php echo esc_html(get_option('mycuisine_address')); ?></p>
            </div>  <!-- end .container -->
        </div> <!-- end #quote -->
    <?php } ?>


    <div class="container fullwidth">

    <div id="content" class="clearfix"> 

        <div id="left-area">

        <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

            <div id="location-left-area">

                <div class="info-block">

                    <h2 class="category_name"><?php esc_html_e('Address','MyCuisine'); ?></h2>

                    <?php echo esc_html(get_option('mycuisine_address')); ?>

                </div> <!-- end .info-block -->



                <div class="info-block">

                    <h2 class="category_name"><?php esc_html_e('Hours Of Operation','MyCuisine'); ?></h2>

                    <p><?php esc_html_e('Monday-Saturday:','MyCuisine'); ?> <span><?php echo esc_html(get_option('mycuisine_mon_fri')); ?></span></p>

                    <p><?php esc_html_e('Sunday:','MyCuisine'); ?> <span><?php echo esc_html(get_option('mycuisine_sat_sun')); ?></span></p>

                </div> <!-- end .info-block -->



                <div class="info-block">

                    <h2 class="category_name"><?php esc_html_e('Contact Info','MyCuisine'); ?></h2>
                    <p><?php esc_html_e('Telephone:','MyCuisine'); ?> <span><?php echo esc_html(get_option('mycuisine_telephone')); ?></span></p>

                </div> <!-- end .info-block -->



                <?php do_action('et_location_additional_info'); ?>

            </div> <!-- end #location-left-area -->



            <div id="gmaps-border" class="location-page">

                <div id="gmaps-container"></div>

            </div> <!-- end #gmaps-border -->



            <script type="text/javascript" src="http://maps.google.com/maps/api/js?v=3.1&sensor=false"></script>

            <script type="text/javascript">

              //<![CDATA[

              var map;

              var geocoder;



              initialize();



              function initialize() {

                 geocoder = new google.maps.Geocoder();

                 geocoder.geocode({

                    'address': '<?php echo esc_js(get_option('mycuisine_address')); ?>',

                    'partialmatch': true}, geocodeResult);   

              }



              function geocodeResult(results, status) {



                 if (status == 'OK' && results.length > 0) {         

                    var latlng = new google.maps.LatLng(results[0].geometry.location.b,results[0].geometry.location.c);

                    var myOptions = {

                       zoom: 15,

                       center: results[0].geometry.location,

                       mapTypeId: google.maps.MapTypeId.ROADMAP

                    };



                    map = new google.maps.Map(document.getElementById("gmaps-container"), myOptions);

                       var marker = new google.maps.Marker({

                       position: results[0].geometry.location,

                       map: map

                    });



                    var contentString = '<div id="et-gmaps-content">'+

                    '<div id="bodyContent">'+

                    '<p><a target="_blank" href="http://maps.google.com/maps?f=q&amp;source=s_q&amp;hl=en&amp;geocode=&amp;q='+escape(results[0].formatted_address)+'&amp;ie=UTF8&amp;view=map">'+results[0].formatted_address+'</a>'+

                    '</p>'+

                    '</div>'+

                    '</div>';



                    var infowindow = new google.maps.InfoWindow({

                       content: contentString,

                       maxWidth: 100,

                       maxHeight: 200

                    });



                    google.maps.event.addListener(marker, 'click', function() {

                       infowindow.open(map,marker);

                    });



                    google.maps.event.trigger(marker, "click");



                 } else {

                    //alert("Geocode was not successful for the following reason: " + status);

                 }

              }

              //]]>

            </script>



            <?php do_action('et_location_content'); ?>

        <?php endwhile; endif; ?>

        </div>  <!-- end #left-area -->



    </div> <!-- end #content -->

    <div id="bottom-shadow"></div>

</div> <!-- end .container -->
<?php } else { ?>
    <div class="container">
        <div id="content" class="clearfix"> 
            <div id="left-area">
                <?php get_template_part('includes/entry','home'); ?>
            </div>  <!-- end #left-area -->

            <?php get_sidebar(); ?>
        </div> <!-- end #content -->
        <div id="bottom-shadow"></div>
    </div> <!-- end .container -->
<?php } ?>

<?php get_footer(); ?>

You can see it live (although, nobody knows about the site yet and it's not nearly finished) here. I have tried removing lines just to see what would happen and I can't sort it out.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

The loop in your code:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

is saying "if I have posts, display them all - by the declared # per page"

So you need to modify the loop to only display the content you need.

Can you provide some information on where the content such as address details are coming from?

share|improve this answer
    
Yes, and thank you! The address details are coming from the data I enter in their (Elegant Themes) admin panel (core_functions.php). I do not need any posts to display as this is going to be a static page and I only want to display the map and the info to the left. HOWEVER, I do have the header's slider pulling from featured posts but I assume that does not apply here because line 1 in the code handles that? –  Jason Cyr Design Oct 31 '12 at 22:05
    
You do not need the loop around the static content you have pulling from the theme admin panel. That will fix your problem. I would have guessed you would need the loop around the slider, so it can display multiple posts - but I am not sure how the template looked before you can editing it. –  Rachel Baker Oct 31 '12 at 22:11
    
FYI removing the loop would require removing this line: <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> and this line (farther down) <?php endwhile; endif; ?> –  Rachel Baker Oct 31 '12 at 22:17
    
Sweeet! Thanks for your help Rachel, now I know what to look for next time. I don't yet know the "why" things like this happen, but I'm learning. –  Jason Cyr Design Nov 1 '12 at 15:44
    
@jason, you should mark this answer as correct if Rachel's helped you figure it out! –  guiniveretoo Nov 2 '12 at 18:47

Your Answer

 
discard

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.