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/
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.