Extract attribute values from every shortcode in post

Method #1 If available, I would use the: shortcode_atts_{$shortcode} filter to collect the attributes of a given shortcode. Example: $text=” “; $out = wpse172275_get_all_attributes( ‘gallery’, $text ); print_r( $out ); with the output: Array ( [0] => [1] => Array ( [ids] => 1,2 https://wordpress.stackexchange.com/questions/172275/extract-attribute-values-from-every-shortcode-in-post => file ) [2] => Array ( [ids] => 3 … Read more

Are php template shortcodes ok?

Is it Ok? Yes! Is it Optimal? No What Would Be Better? Shortcodes map on to PHP functions, so why not cut out the middle man and go straight to the original function? Are there any other downsides? Yes! That shortcode had to come from somewhere, now you have a dependency, maybe the plugin that … Read more

WordPress transients for a shortcode

Use this instead of the line in wich you define $days (your second line): $transient = get_transient( ‘your_transient_key’ ); if( !$transient ): $days = file_get_contents( ‘json_file’ ); set_transient( ‘your_transient_key’, $days, DAY_IN_SECONDS*7 ); else: $days = $transient; endif; $days = json_decode( $days ); … May be a bit rough but you get the idea.

shortcode inside another shortcode

I usually apply the_content filters to $content to do this. I think you can aslo use do_shortcode($content); // Column ShortCode Description function column_scdescription($atts, $content=”null”) { return ‘<div class=”description”>’ .apply_filters(‘the_content’, $content) . ‘</div> <!– description ends here –>’; } add_shortcode (“product-description”, “column_scdescription”); Read up on Nested Shortcodes in the codex.

Stray closing paragraph tag when using shortcodes

This is frustrating issue as I can’t depend on the content editors to be savvy enough with WordPress / HTML to understand how the text they input will be parsed… –EDIT– Having thought of this a bit more I have reconsidered my earlier answer. HTML5+ comes with the Tidy extension, if you are able to … Read more