Can't seem to get [shortcode]s to work
function register_shortcodes(){
add_shortcode( 'my_shortcode', 'my_shortcode' );
}
add_action( 'init', 'register_shortcodes');
function my_shortcode( $atts ) {
return "--my_shortcode--";
}
Adding this code to a plugin I've been making (specifically for this) doesn't do anything. I don't think the function my_shortcode( $atts ) is even called.
I've tried putting "[my_shortcode]" in posts, comments, template(s).php. return "--my_shortcode--"; never executes.
I've also put the above piece of code in functions.php which gives me error
Fatal error: Call to undefined function add_shortcode() in C:\localhost\~\wp-includes\functions.php on line 17
line 17 : add_shortcode( 'my_shortcode', 'my_shortcode' );
function register_shortcodes(){
add_shortcode( 'my_shortcode', 'my_shortcode' );
}
add_action( 'init', 'register_shortcodes');
function my_shortcode( $atts ) {
return "--my_shortcode--";
}
Adding this code to a plugin I've been making (specifically for this) doesn't do anything. I don't think the function my_shortcode( $atts ) is even called.
I've tried putting "[my_shortcode]" in posts, comments, template(s).php. return "--my_shortcode--"; never executes.
I've also put the above piece of code in functions.php which gives me error
Fatal error: Call to undefined function add_shortcode() in C:\localhost\~\wp-includes\functions.php on line 17
line 17 : add_shortcode( 'my_shortcode', 'my_shortcode' );
No comments:
Post a Comment