How to modify specific parts of a post content in WordPress

Finally, I had to add the required code inside another shorcode I had in place to create the content structure. That way I avoided creating an extra shorcode and was able to put the custom code in the exact position I wanted.

Thanks to all those who helped.