In WordPress, you can add a short code that allows you to include a PHP File at your post.
First, add the following function in your child theme’s functions.php template:
function sc_include($atts, $inc) {
return get_include_contents($inc);
}
function get_include_contents($filename) {
ob_start();
// you can change the directory
$filename = get_theme_root().'/'.get_template().'/'.trim($filename);
if (is_file($filename)) {
@include($filename);
}
return ob_get_clean();
}
add_shortcode('include', 'sc_include');
And you can now in your WordPress post, add a short code like this:
This allows the file.php to be included in the wordpress current post/page and be dynamically interpreted by PHP.
Wordpress is King!
- Wordpress: How to Output Full Text in the Feed?
- How to Add Adsense Ads to bbPress Forum?
- Adding Two Short Code Functions to Wordpress: Top Posts By Number of Comments and Top Posts by Ratings
- Adding a Short Code Function to Include Any PHP or HTML Files in the WordPress Posts or Pages
- Free Wordpress T-Shirt by Submitting a Bug Report
- 5 Things to Look For in a WordPress Hosting Provider
- Using the Regular Expression to Replace External Links in Wordpress for SEO purposes
- How to Add a ShortCode to Include a PHP File in Wordpress?
–EOF (The Ultimate Computing & Technology Blog) —
Last Post: Teaching Kids Programming - Two Pointer Algorithm to Solve Four Sum Problem
Next Post: BASH Script to Compute the Average Ping to a Domain