Reputation: 11295
I have very simple custom template. When I try execute do_shortcode from within my php program I get fatal error:
<?php echo do_shortcode('[shortcodename]'); ?>
( ! ) Fatal error: Call to undefined function php do_shortcode() in /var/www/wp/wp-content/themes/musustatymai/category.php on line 17
Call Stack
# Time Memory Function Location
1 0.0000 233208 {main}( ) ../index.php:0
2 0.0001 233640 require( '/var/www/wp/wp-blog-header.php' ) ../index.php:17
3 0.0376 2924360 require_once( '/var/www/wp/wp-includes/template-loader.php' ) ../wp-blog-header.php:16
4 0.0387 2938176 include( '/var/www/wp/wp-content/themes/musustatymai/category.php' ) ../template-loader.php:75
What can be wrong with my template, as I know that is not needed to load wordpress classes manually to get access to methods. Also I tried using includes.
wp-includes/shortcodes.php
but get same error.
Upvotes: 1
Views: 1239
Reputation: 382
Be sure you have write/load [shortcodename] also in your post, because only writing it in the template alone won't work.
jThis just searches for the shortcode in the post when the loop starts, in order to put the shortcodename elsewhere.
This may explain more: https://ardamis.com/2011/06/02/fix-for-php-fatal-error-get_header-in-wordpress/
Upvotes: 1