• hello forum

    I have a custom theme on our website that is does not have the wordpress loop working correctly on some of our .php template pages.
    This has meant that we have a plugin – wp reviews pro – that uses short codes to show a review box – but the review box shortcode just shows the text for the short code. The shortcake can currently be seen on the page.

    Here is the code for the template page;
    Can anybody advise me on the code to change to put the wordpress loop for content correctly in the php.

    <?php 
    /* Template Name:Hazel Grove */
    get_header(); ?>
    <!--Kid Animation-->
          <div class="kid">
            <div class="container has-feedback">
              <span id="kid1">&nbsp;</span>
              <span id="kid2">&nbsp;</span>
              <span id="kid3">&nbsp;</span>
              <span id="kid4">&nbsp;</span>
            </div>
          </div>
          <div class="clearfix"></div>
          </div>
          <div class="container">
              <div class="row">
                <div class="col-xs-12">
                  <div class="common_submenu">
                    <ul class="l2nav">
                     
                         <li><a href="<?php echo site_url(); ?>/electricians-in-bramhall"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Bramhall</a></li>
                    <li><a href="<?php echo site_url(); ?>/electrician_cheadle_hulme">Cheadle Hulme</a></li>
                    <li class="active"><a href="<?php echo site_url(); ?>/electrician-in-hazel-grove"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Hazel Grove</a></li>
                    <li><a href="<?php echo site_url(); ?>/electrician_poynton"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Poynton</a></li>
                    <li><a href="<?php echo site_url(); ?>/electrician_stockport"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Stockport</a></li>
                    <li><a href="<?php echo site_url(); ?>/electrician_wilmslow"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Wilmslow</a></li>
                     <li><a href="<?php echo site_url(); ?>/electrician_manchester"><img src="<?php echo get_template_directory_uri(); ?>/images/menu.png" class="menu-image">Manchester</a></li>
                    </ul>
                  </div>
                </div>
              </div>
            </div>
          </div>
    
           <section>
            <div class="service_area_wrapper">
              <div class="container">
                <div class="row">
                  <div class="col-sm-12 col-md-8">
                  <div class="about_service">
                       <?php $feat_image=wp_get_attachment_url(get_post_thumbnail_id($post->ID)); ?>
                      <img src="<?php echo $feat_image; ?> " alt="" title="">
                    <?php echo $post->post_content; ?>
                    </div>
                  </div>
    
                  <div class="col-sm-12 col-md-4">
                    <div class="service_side_review">  
                      <div class="side_review">
                         <p class="about_customer_feedback"><a href="<?php echo site_url(); ?>/reviews">Customer Feedback <span>(View all »)</span></a></p>
                       <?php echo do_action( 'wprev_pro_plugin_action', 2 ); ?>
                      </div>
                    </div>
    
                    <div class="area_contact_form">
                      <?php echo do_shortcode('[contact-form-7 id="172" title="Area Page Form"]'); ?>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </section>
    
          <div class="area_map">
            <div class="container">
              <div class="row">
                <div class="col-xs-12">
                  <?php echo get_post_meta($post->ID,'map_content',true); ?>
                </div>
              </div>
            </div>  
          </div>
          <script src="<?php echo get_template_directory_uri(); ?>/js/jquery-1.11.2.min.js"></script>
       <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-validate/1.10.0/jquery.validate.min.js"></script>
           <script>
      /**** contact form validation ****/
      jQuery.validator.addMethod("lettersonly", function(value, element) {
          return this.optional(element) || /^[a-z]+$/i.test(value);
      },"Letters only please");
    
      /**** contact page form validation ****/
      $( ".wpcf7-form").validate({
          rules: {
            fname: {
                required: true,
                minlength: 3,
                lettersonly: true
            },
          areaemail:{
            required: true,
            email: true
          },
          areaphone: {
            required: true,
            number: true,
            minlength: 7,
            maxlength: 15,
            },
            areasubject: {
            required: true
          },
           areamessage: {
            required: true
          }
          },
          messages:{
            fname:{ 
              required: "You can't leave this empty.",
              minlength: "Name should be more than 2 characters",
                lettersonly: "Please enter only letters"
              },
            areaemail:{ 
              required: "You can't leave this empty.",
              email: "Please enter correct email."
            },
            areaphone: {
                required: "This field is required",
                number: "Please enter only numbers",
                minlength: "Number should be more than 6 digits",
                maxlength: "Number should not be more than 15 digits"
            },
            areamessage: "You can't leave this empty."
        },
          onfocusout: function(element) {
              this.element(element);
          },
      });
      /**** contact page form validation ****/
    </script>
          <?php get_footer(); ?>
    

    Thank you in advance!!!

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter danielrossthomas

    (@danielrossthomas)

    further information – I am told its the ‘content’ loop info we need to work. Hope that helps.

    You’ll be able to see examples of the loop in most template files in your theme, specially ones like index.php, archive.php and even single.php if it’s set up right.

    Basically it’s like this:

    while( have_posts() ) {
        the_post();
    
        // Do whatever template calls you need to in here.
    }
    Thread Starter danielrossthomas

    (@danielrossthomas)

    Thanks, I had. developer create a custom theme for our site so most pages are missing the wordpress loop feature as it has been custom coded.

    Could you help me with what code to put in / change in the above?
    (FYI – I am a php learner – learning to walk 🙂
    hence some help would be much appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Help with template code’ is closed to new replies.