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

Display sorting options dropdown when using WooCommerce product category shortcode

Since WooCommerce 3.2, Woocommerce shortcodes and their available attributes have changed. So try the following shortcode instead (for “foo” product category): [product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”] or inside php code: echo do_shortcode( ‘[product_category limit=”90″ columns=”3″ category=”foo” paginate=”true”]’ ); Now you will see that the sorting options dropdown appear. Note: orderby argument with an empty value … Read more

Multiple Parameters for a Shortcode

Lets look at the shortcode [SH_TEST var1=”somevalue” var2=”someothervalue”]THE SHORTCODE CONTENT[/SH_TEST] the shortcode handler function accepts 3 paramters $atts – an array of attributes passed by the shortcode in our case: $atts[‘var1’] is set to ‘somevalue’ $atts[‘var2’] is set to ‘someothervalue’ $content – is a string of the value enclosed with in the shortcode tags, in … 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.

Enabling shortcodes for custom fields

Normally WordPress does not run shortcode that you put into a custom field. By default, Custom Fields display whatever value you enter, as plain-text, so if you try entering a shortcode, (in the format [shortcode] VALUE [/shortcode]) you’ll end up displaying the entire text, including the tags. Add the following in your template file, it … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)