Skip to content
Advertisement

While Loop displays arguments inside the first argument

I have a while loop created to display all my wordpress posts. The issue is that all the posts (except the first) appear inside the first post.

I’ve check my div structures and I couldn’t find any issues. The loop is working, but the div isn’t showing in the right place.

JavaScript

What is expected is 4 different posts inside the “slider-vertical” div displayed at the same level in the HTML structure. The actual result is the first post at the correct level and then the next posts 2 levels deeper inside the first post.

Advertisement

Answer

this kind of problem occurs when there is a not properly closed HTML tag on the first execution of the loop, try to use a short statement syntax

JavaScript

check also the content printed by <?php echo $content ?> of the first post, may contains an open HTML tag.

You can easily check the generated code using the souce view (CTRL+U) in Firefox that highlights in red the wrong HTML closing tags

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement