Search
Close this search box.

How to use shortcode with ob_start and ob_end_clean() ?

Amitpal Singh
Amitpal Singh
October 15, 2020
function callback(){
	ob_start();
	?>
	Content goes here
	<?php
	$output_string = ob_get_contents();
	ob_end_clean();
	return $output_string;
}
add_shortcode('shortcodename','callback');

Now use [shortcodename] like this anywhere in the page or in between the post.

ob_get_contents() will help to tell the actual position of the shortcode.

Share this post:

How to Attribute?

Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
for Example: Website, Social Media, Blogs, ebooks , newsletter, etc.
Lorem ipsum is typically a corrupted version of De finibus bonorum et malorum, a 1st-century BC text by the Roman statesman and philosopher Cicero.
Copied!

Got a Question? Check out our FAQ Section.

Your action, our appreciation

It encourage us to give you more valuable content on website.