Problem:
We need to create a custom code sniper inside our wordpress, for example add a message with the date and time then the page is open.
Solution:
1.- Create a function inside funtions.php of our wordpress, the file is located in /httpdocs/wp-includes as global or inside your template theme folder
function sc_mycustomcodefunction() {
//bla bla bla, custom dode of our funtion
return ‘today will be agreat day’;
}
2.- Create the shortcode, just at the end of the file functions.php
add_shortcode('SC01', 'sc_mycustomcodefunction');
3.- Inside the page of wordpress call the whostcode following the next sintaxys.
[SC01]
Details:
The function that contains the php code is sc_mycustomcodefunction
The shorcode is created with a wordpress function add_shortcode inside function.php
The parameters of the standard wordpress function add_shortcode are: ( <ShorCodeName>,<FunctionName> )
ShorCodeName is SC01 in our exxample
FunctionName is sc_mycustomcodefunction