Hi there,
I’m not quite sure how this is supposed to work but the main thing is that you don’t want to modify the theme’s core files.
I would recommend using a child theme for something like this:
https://docs.generatepress.com/article/using-child-theme/
The instructions shouldn’t be theme specific – it would be the same to implement in a twenty series WP theme and GP.
The author is quite active in the comment section too so that might be a good place to go if you run into problems.
Hope this helps!