reference from your functions.php to your shortcodes.php
So your functions.php could start like
<?php
// define the path
$shortcodes_path = get_template_directory() . '/shortcodes';
// ** Get the shortcodes.php **
require_once $shortcodes_path . '/shortcodes.php';
This code will now on start load a file called "shortcodes.php" stored in a folder "shortcodes".
The line after define the path sets a shortcut the your themes folder and right there into a subfolder called "shortcodes".
The line direct after Get the shortcodes.php loads a file called "shortcodes.php" stored in that folder "shortcodes". So you could put all your css, js and so on cleaned up in a folder, using the $shortcodes_path to load the ressource.
Now you need to place the shortcodes file in this folder with the right name example could be
<?php
/* show content on mobilephones only */
function showm( $atts, $content = null ) {
$content = wpautop(trim($content));
return '<div class="visible-xs">'.do_shortcode($content).'</div>';
}
add_shortcode("show-m", "showm");
save and shoot. IF you're using bootstrap this shortcode will wrap your content into a div which will only be displayed on mobile devices.
two things:
1. As this is php it doesn't need a closing php tag, but if you're a cleancode-lover you'll do it anyway.
2. allways use "do_shortcode($content)" as this will allow the user to use a shortcode wrapped in a shortcode. FE: If you have the above shortcode for mobile devices and a shortcode for icons the user could use the icon shortcode to be displayed on mobile only.
SO MUCH WOW =) All the best
Fab
wp-includesdirectory, that is core WP stuff and shouldnt be messed with unless you know exactly what you are doing. you should add this to thefunctions.phpin your active theme. if you are using a child theme, you can add afunctions.phpto that with just your shortcode in it