Pass instance number to shortcode child

You can wrap it in a class. Here’s an example: class WPSE_Answers_Counting { private $instance_answers = 0; private $instance_prev_answers = 0; private $instance_answer = 0; public function init() { add_shortcode( ‘answers’, [ $this, ‘answers_shortcode’ ] ); add_shortcode( ‘ans’, [ $this, ‘answer_shortcode’ ] ); } public function answers_shortcode( $atts = [], $content = null ) { … Read more

tax query shortcode

You just want to make sure you get all your default attributes set in addition to only adding tax queries when you have all the values set. <?php // [loop post_type=”website” taxonomy=”industry” terms=”beauty” posts=”3″][/loop] // [loop post_type=”website” posts=”-1″ ][/loop] function loop_recent_posts_shortcode( $atts ) { $a = shortcode_atts( array ( ‘posts’ => 6, ‘post_type’ => ”, … Read more

Basic custom Shortcode not working

get_the_content returns the content as is without processing, it does not pass it through the filters that are used in the_content such as oembeds or shortcodes. This filter is also called the_content ( coincidence ) Instead use this: $email_body = apply_filters( ‘the_content’, get_the_content() );

caption shortcode using image alt as caption

To remove caption text, you can override the caption short-code using below code: add_filter( ‘img_caption_shortcode’, ‘my_img_caption_shortcode’, 10, 3 ); function my_img_caption_shortcode( $empty, $attr, $content ){ $attr = shortcode_atts( array( ‘id’ => ”, ‘align’ => ‘alignnone’, ‘width’ => ”, ‘caption’ => ” ), $attr ); if ( 1 > (int) $attr[‘width’] || empty( $attr[‘caption’] ) ) … Read more