I have read this stack article, but it refers to themes.
It does not. The word "theme" is mentioned nowhere in the question or answers. Edit: Apparently it mentions functions.php. Regardless, the below still applies.
Do I basically do the same in the plugin's activation method?
You do not need to (and should not) use the activation method of the plugin. The code from the answer can go anywhere in a plugin or theme.
Developing themes and plugins is essentially the same process, with the same code. The only differences are:
- WordPress will only automatically load template files from themes.
- Plugins are loaded/run before the theme.
- You need to use different functions to get the path or URL of plugins (eg.
plugins_url()) to those used for themes (eg.
- Functions that should only run once when the plugin or theme is activated are hooked differently.
Plus the philosophical difference that themes should be responsible for presentation, and everything else belongs in a plugin.
Any code you see for doing something in WordPress will work the same ina theme or plugin unless any of the above points are relevant.