You need all that code, as it’s overwriting a core GP function.
Feel free to open a new topic (this one is super old) with the code you’re now using, and I’ll see if we can use a filter instead of the full function. Also, be sure to let me know if you made any other changes to the function, or if it’s only the single post links.