In general, special theme functionality (including shortcodes) should be placed in your theme’s functions.php
file, which is in the root of your theme folder. If the code is less than a few dozen lines, it probably won’t be worth creating a separate file (unless you just really want to organize your code that way).
So the shortcode functionality and the add_shortcode()
call should be in functions.php.
Let’s say you do want to separate it though. You can include your myShortCodes.php
file like this in your functions.php file:
require_once('myShortCodes.php');
And then you can have the code (including the add_shortcode()
call) kept in myShortCodes.php
.
It’s recommended to not alter the WordPress core files (like wp-includes/shortcodes.php) or put anything in the wp-includes folder because then it’s outside of your theme folder and any upgrades to the WP core will cause your changes to be lost.