wb_posts_pagination()
seems to be a custom function that sends its output directly to the browser with echo
or print
.
Use a function that returns a string and does not create output to add that string to $content
.
The printed output doesn’t wait, it goes into the page the moment you call that function.