If I call the popular posts below “the content” it works without any
problem. If I call it before it (like in the code above), the actual
content of my page won’t show up and instead the last blog post in the
list of popular posts will be displayed.
If I understand you, that is because the_content
depends upon the global $post
value, which is set very early in the page load but then reset by the the_post
method in your Loop. Early in the page it is set to your page’s content. The secondary loop then overwrites it at each iteration. After the Loop completes $post
is populated with the last post in the Loop.
If you need the original post data after you run that Loop you should be using wp_reset_postdata
. That should reset $post
back to the current post in the main query. In your case that would be your page content.
Also, you should not be running the_content
outside of a proper Loop. It is meant to run inside the Loop will not always behave as you expect otherwise.