Home » Uncategorized » Creating shortcut codes in WordPress

Creating shortcut codes in WordPress

Simply in your theme’s function.php file add the following:

add_shortcode( 'fab-sc-helloworld', 'fab_helloworld');
function fab_helloworld(){
// add your code here
 echo 'hello world';
}

In a page or post using the text editor add the following line

[fab_helloworld]

Now view your page/post.

Once this is working, simply replace “echo ‘hello world’;”  with whatever PHP code you wish.

 

Support