Wordpress shortcode in custom post type -
i'm trying post shortcode in custom post type has function add news keeps displaying shortcode , not shortcode content.
in theme's functions.php have added:
add_filter( 'insertpages_init', 'shortcode_unautop'); add_filter( 'insertpages_init', 'do_shortcode' );
and function in insertpages plugin follow:
function insertpages_init() { add_shortcode('insert', array($this, 'insertpages_handleshortcode_insert')); }
making post custom type post still prints shortcode instead of content. can work wish using example:
add_filter('widget_text', 'do_shortcode');
and works fine.
how can custom post type accept shortcodes?
i think problem on insertpages_init filter, general form of adding short code :
function footag_func( $atts ) { return "foo = {$atts['foo']}"; } add_shortcode( 'footag', 'footag_func' );
and if want load on init action :
add_action( 'init', 'load_footag_shortcode' ); function footag_func( $atts ) { return "foo = {$atts['foo']}"; } function load_footag_shortcode(){ add_shortcode( 'footag', 'footag_func' ); }
Comments
Post a Comment