From 3a4ef4c318cb732cf64c1ab39a4a2b964b26d2da Mon Sep 17 00:00:00 2001 From: Aaron Ware Date: Mon, 7 Jan 2019 13:54:54 -0500 Subject: [PATCH] Shortcodes should return a value not output require will output by default. Previous implementation results in broken pages within the REST API if the shortcode is used. --- includes/kbe-core-functions.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/kbe-core-functions.php b/includes/kbe-core-functions.php index dcab589..63429a3 100644 --- a/includes/kbe-core-functions.php +++ b/includes/kbe-core-functions.php @@ -123,8 +123,14 @@ function boxCloser(e) { */ function kbe_shortcode( $atts, $content = null ) { if ( !is_admin() ) { - $return_string = require dirname( __FILE__ ) . '/../template/kbe_knowledgebase.php'; + ob_start(); + + require dirname( __FILE__ ) . '/../template/kbe_knowledgebase.php'; wp_reset_query(); + + $return_string = ob_get_contents(); + ob_end_clean(); + return $return_string; } }