Permalink Short code showing unnecessary link text inside the loop

ob_get_flush doesn’t do what you think it does. You’re assuming that it only ends the output buffer and returns its contents, which is incorrect, it also flushes the output buffer to the browser.

So this:

return ob_get_flush();

Is the same as this:

$content = ob_get_clean();
echo $content;
return $content;

Use ob_get_clean(); instead, which erases the output buffer instead of flushing it.