Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Shortcode in WordPress
// include a specific PHP file
function customIncludeFile($params = array()) {
extract(shortcode_atts(array(
'file' => 'contact-form'
), $params));
ob_start();
include(get_theme_root() . '/' . get_template() . "/$file.php");
return ob_get_clean();
}
add_shortcode('include', 'customIncludeFile');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment