2
votes

I'm trying to use a the function do_shortcode() outside the loop of Wordpress. I required wp-load.php and shortcodes.php on top of the file, but when i use do_shortcode('[converter']); the function only outputs the text [converter], not the function of the shortcode.

Does anyone know how to make the shortcode work?

Thanks in advance

1
Please use like this if your shortcode does not have error then its works <?php echo do_shortcode('[converter']'); ?> - Sp.
I was echoing the function, after a while i found out that the problem was that i only required wp-load.php, the solution was to require following instead: define( 'WP_USE_THEMES', false ); require($_SERVER['DOCUMENT_ROOT'] .'/wp-config.php'); - Max

1 Answers

0
votes

wp-load.php wasn't the right file to require, the solution was to require the following:

define( 'WP_USE_THEMES', false );        
require($_SERVER['DOCUMENT_ROOT'] .'/wp-config.php');