Support

Account

Home Forums General Issues Need guidance on code cleanup Reply To: Need guidance on code cleanup

  • This forum isn’t really for general coding questions, it’s for questions about how to use ACF, but I’ll get you on your way.

    The first thing you need to do is start using white space and indenting. Here’s a very simple example.

    
    <div>
      <?php 
        if (get_field('my_field')) {
          ?>
            <p><?php the_field('my_fielde'); ?></p>
          <?php 
        } // end if get_field('my_field')
      ?>
    </div>
    

    With proper indenting and white space errors become apparent. Here is your code when I attempt to apply this to it. Things that are missing or incorrect stand out

    
    <div class="incident_info">
      <p class="doc_type"><!-- no closing tag or improperly nested -->
        <em>
          <strong><!-- no closing tag or improperly nested -->
            <?php si_e('Additional Incident Information:') ?><br><br>
        </em>
        <?php 
          if(get_field('incident_type')) // where does this if end?
            ?>
              <!-- no such thing as a class element, what is this -->
              <!-- <class="incident_type"> commented out the unknown element 
                  assuming you meant p
              -->
              <p class="incident_type">
                <?php echo get_field(incident_type) ?><br><br>
              </p>
              <p class="doc_type"><!-- no closing tag -->
                <?php 
                  if(get_field('incident_location')) // where does this if end?
                    ?> 
                      <p class="incident_location">
                        <?php echo get_field(incident_location) ?> <br><br>
                      </p>
                      <p class="doc_type">
                        <?php 
                          if(get_field('incident_ordinance')) // where does this if end
                            ?> 
                              <class="incident_ordinance">
                                <?php echo get_field(incident_ordinance) ?> <br><br>
                              </class="incident_ordinance">
                              </strong><!-- closing tag is not matched or improperly nested -->
                      </p>
    </div>
    

    This site has some online coding classes that are free and I’ve been told that they are pretty good. https://www.codecademy.com/