This is a really good way of adding some custom code without having to create a new WP plugin. Simply add a php file to your wordpress and display the result using a shortcode.
Just remember: Don’t use echo or print in your functions or the output will be displayed above your post and not where your shortcode is. To display contents correctly always return them as shown in the examples.
To render template files with lots of html:
ob_start() require 'my_custom_template.php'; $contents = ob_get_contents(); ob_end_clean();
The resulting output will be stored in the $contents variable thanks to the output buffer. The template file can contain php which will be interpreted like every file that is being included using require().
- The topic ‘Great way to add custom functionality’ is closed to new replies.