Printing fieldable panel pane custom field in template properly I've created a fieldable panel pane that has two fields, a title and a body. My template file looks like this:

&lt;div class="sidebar-pane"&gt;
    &lt;h2 class="pane-title"&gt;
        &lt;?php print render($content['field_pane_title']); ?&gt;
    &lt;/h2&gt;
    &lt;div class="pane-content"&gt;
        &lt;?php print render($content['field_body']); ?&gt;
    &lt;/div&gt;
&lt;/div&gt;


This seems fairly basic. Now, when I actually add one of these panes to a page, this is the DOM that is spit out:

&lt;div class="sidebar-pane"&gt;
    &lt;h2 class="pane-title"&gt;&lt;/h2&gt;
    &lt;h3 class="field-label"&gt;&lt;/h3&gt;
    Test Pane   

    &lt;div class="pane-content"&gt;
        &lt;h3 class="field-label"&gt;&lt;/h3&gt;

        &lt;p&gt;This is a test body.&lt;/p&gt;
    &lt;/div&gt;
&lt;/div&gt;


Ignoring the fact that it's printing out empty field-label elements, why is the pane-title field being printed outside the pane-title h2 element? Is there a better way to be doing this? Thanks!
Ignoring the empty field-labels was a problem! The issue was with those field labels, which were generated by the Fences module. They were somehow causing the h2 to close too early.

I ended up modifying the module myself, so that the template checks if a field label exists before adding it to the DOM.

I also ended up finding an issue on the module's issue page which has a patch to fix it directly, in case anyone is interested: https://www.drupal.org/node/2605808