plugin how to find code and edit it in a template file?

I know add id for each loop is not an existing hook I just put it there as I was hoping someone could tell me the right hook to use.
To give you more a sense of what I am trying to do. hopefully this link will help. I have everything working just trying to port/move it to a plugin. As for re-loading jquery I found it didn’t work on a previous code so I will re-examine it.

So its impossible to modify a template file from a plugin? could I reset the query and make a new loop in the plugin to add the id?
Link