Title: [loop] and HTML
Last modified: August 21, 2016

---

# [loop] and HTML

 *  Resolved [jheckergld](https://wordpress.org/support/users/jheckergld/)
 * (@jheckergld)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/loop-and-html/)
 * I am not sure if it is the ‘WYSIWYG’ editor mucking up what I am trying to do,
   or if it is something with saving the page and how it is escaping HTML codes,
   or what, but here is my situation:
 * This is the code I have, which is quite simple:
 *     ```
       <table style="width: 100%;" cellspacing="15" cellpadding="15">
       		<tbody>
       			[loop type='post' category='Products']
       			<tr>
       				<td colspan="2" align="center">
       					<h2>
       						<strong>
       							<span style="text-decoration: underline;">
       								[content field='title']
       							</span>
       						</strong>
       					</h2>
       				</td>
       			</tr>
       			<tr>
       				<td width="25%" align='center'>
       					<img style="width: 100%; max-width: 150px;" alt="" src="[content field='image-url']" />
       					<br >
       					[content field='cart_Price']
       					</td>
       				<td>
       					[content]
       				</td>
       			</tr>
       			<tr>
       				<td colspan="2">
       					<hr />
       				</td>
       			</tr>
       			[/loop]
       		</tbody>
       	</table>
       ```
   
 * I input that into the content of a page, on the ‘text’ tab, not the ‘visual’ 
   tab of the editor. I save it, look at it on the front end and everything appears
   exactly how it should, all laid out nice and pretty in a table, etc. However,
   if I go to edit that page again, the editor moves my [loop] tags and it looks
   like this in the editor:
 *     ```
       [loop type='post' category='Products'][/loop]
       <table style="width: 100%;" cellspacing="15" cellpadding="15">
       <tbody>
       <tr>
       <td colspan="2" align="center">
       <h2><strong>
       <span style="text-decoration: underline;">
       [content field='title']
       </span>
       </strong></h2>
       </td>
       </tr>
       <tr>
       <td align="center" width="25%"><img style="width: 100%; max-width: 150px;" alt="" src="[content field='image-url']" />
   
       [content field='cart_Price']</td>
       <td>[content]</td>
       </tr>
       <tr>
       <td colspan="2">
   
       <hr />
   
       </td>
       </tr>
       </tbody>
       </table>
       ```
   
 * I need to move the opening and closing loop tags back to where they belong every
   time I make any changes (which right now is quite often, as I am in the process
   of building this page).
 * Is there something with the WYSIWYG editor that is causing this? Or perhaps something
   with WP and how it saves the contents of the page?
 * For what it is worth, I have disabled any MCE Plugins that were installed (TinyMCE,
   UltimateMCE, Black Studio TinyMCE, etc)
 * [https://wordpress.org/plugins/custom-content-shortcode/](https://wordpress.org/plugins/custom-content-shortcode/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/loop-and-html/#post-4701603)
 * I believe it’s WordPress formatting the text when the post is saved. I recommend
   using [Raw HTML](http://wordpress.org/plugins/raw-html/).
 * Another solution is to put the code in a separate file, and load it in to the
   page using the [load] shortcode.
 * Let me know if that solves your issue.
 *  Thread Starter [jheckergld](https://wordpress.org/support/users/jheckergld/)
 * (@jheckergld)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/loop-and-html/#post-4701741)
 * What I ended up doing was taking the [loop] and [/loop] tags out of the table
   itself, and put them around the table, so it looks like this now:
 *     ```
       [loop type='post' category='Products']
       <table style="width: 100%;" cellspacing="15" cellpadding="15">
       <tbody>
       <tr>
       <td colspan="2" align="center">
       <h2><strong>
       <span style="text-decoration: underline;">
       [content field='title']
       </span>
       </strong></h2>
       </td>
       </tr>
       <tr>
       <td align="center" width="25%"><img style="width: 100%; max-width: 150px;" alt="" src="[content field='image-url']" />
   
       [content field='cart_Price']</td>
       <td>[content]</td>
       </tr>
       <tr>
       <td colspan="2">
   
       <hr />
   
       </td>
       </tr>
       </tbody>
       </table>
       [/loop]
       ```
   
 * Now, rather than creating the loop in the middle of the table outside of any 
   cells, it is created outside of the table, and ends outside of the table, so 
   basically I now have a table for each time the loop, well, loops. It works good,
   and looks alright, so no harm no foul.
 *  Plugin Author [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * (@miyarakira)
 * [12 years, 2 months ago](https://wordpress.org/support/topic/loop-and-html/#post-4701763)
 * I see, that is strange how the shortcode was moved around. Well, I’m glad you
   found the solution, and thanks for letting me know.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[loop] and HTML’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/custom-content-shortcode_766976.svg)
 * [Custom Content Shortcode](https://wordpress.org/plugins/custom-content-shortcode/)
 * [Support Threads](https://wordpress.org/support/plugin/custom-content-shortcode/)
 * [Active Topics](https://wordpress.org/support/plugin/custom-content-shortcode/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/custom-content-shortcode/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/custom-content-shortcode/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Eliot Akira](https://wordpress.org/support/users/miyarakira/)
 * Last activity: [12 years, 2 months ago](https://wordpress.org/support/topic/loop-and-html/#post-4701763)
 * Status: resolved