My previous theme had an area called “Scripts” below the editor on every post or page that would allow me to add JavaScript or whatever else into the header or before the closing body tag for that specific post/page only rather than have it load site-wide.
Is there a way to do something like this in GeneratePress, preferably without using a plugin?
I think this might work perfectly for what I need. My only questions would be…
1. This was posted a couple of years ago. Is it still the way to do it?
2. I’d want to do this for posts rather than pages. So instead of “is_page” would it need to be “is_post” or “is_single”?
3. To add the same script to multiple pages, would I just need to use commas? For example: <?php if ( is_post( ‘100, 101, 102’ ) ) : ?>
I should also mention that 2 & 3 won’t be needed once GPP 1.7 comes out. It’s currently in beta 3 already so pretty stable I think. It might save you some work if you want to try it out: https://docs.generatepress.com/article/beta-testing/