Reputation: 311
I'm trying to post a shortcode in a custom post type that has the function to add news but it just keeps displaying the shortcode itself and not the shortcode content.
In my theme's functions.php I have added:
add_filter( 'insertPages_init', 'shortcode_unautop');
add_filter( 'insertPages_init', 'do_shortcode' );
and the function in my insertpages plugin is as follow:
function insertPages_init() {
add_shortcode('insert', array($this, 'insertPages_handleShortcode_insert'));
}
Making a post from the custom type post still just prints the shortcode instead of its content. I can get it to work as i wish using example:
add_filter('widget_text', 'do_shortcode');
and that works just fine.
How can I get my custom post type to accept shortcodes?
Upvotes: 0
Views: 194
Reputation: 114
I think the problem on insertPages_init filter, the general form of adding a short code is :
function footag_func( $atts ) {
return "foo = {$atts['foo']}";
}
add_shortcode( 'footag', 'footag_func' );
and if you want to load on init action like :
add_action( 'init', 'load_footag_shortcode' );
function footag_func( $atts ) {
return "foo = {$atts['foo']}";
}
function load_footag_shortcode(){
add_shortcode( 'footag', 'footag_func' );
}
Upvotes: 0