I thought creating shortcodes was a difficult thing to do, but surprisingly it’s not. I have Theme installed, so this tutorial will be geared towards users with the Theme. If you do not have Thesis, you can still edit your functions.php file and follow the same steps.
Thistutorial will guide Thesis theme users how to create a shortcode for Google code and how to add it into your WordPress posts.
For example, I want:
- I want to be able to use the shortcode in my posts simply by typing [my5links]
- Login to your Google Adsense to create, configure and get your Adsense code
- Backup and Edit Thesis custom_functions.php
- Add shortcode syntax into the Thesis custom_functions.php
- Create a post and use the Adsense Shortcode
- View your post
- Create our own Adsense code.
- Your adsense code will look something like this:
2. Backup and Edit Thesis ‘custom_functions.php’
- Login to your FTP File Manager and take a backup of your Thesis custom_functions.php.
- The file is located in your thesis themes custom folder, IE:
- Login to your WordPress Administrator Panel
- Click on Thesis, Custom File Editor
- Currently editing, Use the drop down to select ‘custom_functions.php‘
- Click on ‘Edit selected file’
3. Add Shortcode code into Thesis ‘custom_functions.php’
- In the custom_functions.php file, go to the bottom of the file and append the following code. Remember to use your own Adsense code:
- Your shortcode string will be [my5links]. Use that anywhere on your WordPress website and Google Adsense 5 links will show up.
- Click on ‘Save’
4. Create a post and use the Adsense Shortcode
- Click on Posts, Add New
- In the body of the post, add in this text:
- See the screenshot for an example
- Save and publish your post.
5. View your Post
- View your post and you will see that your shortcode [my5links] will automatically convert to adsense code.