Freddy
Freddy

Reputation: 867

Call to undefined function do_shortcode in custom shortcode

I'm creating a custom element for the WPBakery plugin and receiving an error when adding do_shortcode($content).

My element is named hero.php and its function is as follows (in WPBakery):

Visual:

enter image description here

A var_dump($content) spits out the fields and values, which are correct, but unsure why do_shortcode is undefined?

Below is where the function is called:

<?php

public function hero_html( $atts, $content = null) {
	$output = 
	$el_class = 
	
	extract( 
		shortcode_atts( 
			array(
				'el_class' 				=> '',
				'css' 					=> '',
			), $atts 
		) 
	);
	
	static $i = 0;

	$output = '<div id="slickslider-'.$i++.'">'.do_shortcode($content).'</div>';
	
	return $output;

}

public function hero_content_html( $atts, $content = null ) {
	
	$output = 
	$title =

	extract( 
		shortcode_atts( 
			array(
				'title'   				=> '',
			), $atts 
		) 
	);
	

	$output .= '
				<!-- Slide -->
				<div class="heroSlider">';

	$output .= '
					<div class="container">
						<div class="row">
							<div class="col-10">
							'(!empty($title) ? '<h1>' . $title . '</h1>' : "" );'
							</div>
						</div>
					</div>
					
				</div>
				<!-- Slide -->
			';
	
	return $output;
		
	}
     
} 

?>

Upvotes: 0

Views: 1563

Answers (1)

Maaz Ali
Maaz Ali

Reputation: 83

Please check for the file wp-load.php whether it's being loaded before this page or not. For running do_shortcode() ,wp-load.php is required.

Upvotes: 2

Related Questions