1function create_shortcode(){
2 return "<h2>Hello world !</h2>";
3}
4add_shortcode('my_shortcode', 'create_shortcode');
5// Use [my_shortcode]
1// function that runs when shortcode is called
2function wpb_demo_shortcode() {
3
4// Things that you want to do.
5$message = 'Hello world!';
6
7// Output needs to be return
8return $message;
9}
10// register shortcode
11add_shortcode('greeting', 'wpb_demo_shortcode');
1function wp_demo_shortcode() {
2
3//Turn on output buffering
4ob_start();
5$code = 'Hello World';
6ob_get_clean();
7
8 // Output needs to be return
9return $code;
10}
11
12// register shortcode
13add_shortcode('helloworld', 'wp_demo_shortcode');
1// function that runs when shortcode is called
2function wpb_demo_shortcode() {
3
4// Things that you want to do.
5$message = 'Hello world!';
6
7// Output needs to be return
8return $message;
9}
10// register shortcode
11add_shortcode('greeting', 'wpb_demo_shortcode');
12