How to parse this shortcode?

shortcode_parse_atts will give you managable information. $atts = shortcode_parse_atts( ‘[soundcloud url=”http://api.soundcloud.com/tracks/67658191″ params=”” width=” 100%” height=”166″ iframe=”true” /]’ ); You will get an array that looks like this: array(7) { [0]=> string(11) “[soundcloud” [“url”]=> string(41) “http://api.soundcloud.com/tracks/67658191” [“params”]=> string(0) “” [“width”]=> string(5) ” 100%” [“height”]=> string(3) “166” [“iframe”]=> string(4) “true” [1]=> string(2) “/]” } You can the … Read more

How do I add text in a shortcode?

hello you can try this // Add Shortcode function text_shortcode( $atts , $content = null ) { // Code return ‘<div>’ . $content . ‘</div>’; } add_shortcode( ‘b’, ‘text_shortcode’ ); The shortcode will be something like this [b] content [/b]

Remove hyperlink on gallery shortcode

Update: It looks like there exists an attribute link=”none” after all 😉 For example: So we don’t need to reinvent the wheel, like in my previous answers 😉 Previous: Plugin to handle link=”no” in the gallery shortcode: Here’s a demo plugin to add the option to remove the image links in the gallery. You can … Read more

Video shortcode – autoplay all videos

I ran into this problem while trying to make HTML videos behave like GIFs. WordPress’s built-in video player uses HTML video elements but does not allow videos to play simultaneously. Instead of using the default WordPress video player (which is best used for more standard video content), I chose to manually use the <video> element … Read more

Execute shortcode twice in the same page

I believe the real issue you had was with echoing your data instead of returning it. A shortcode should return the output to be drawn, which is then drawn in place of the short code. Here is the code using HEREDOC syntax for outputs and the query. I believe this makes things much more readable … Read more

Add attribute to shortcode dynamically

Untested (and can’t test right now) but you ought to be able to add attributes with a filter… something like: function test_sc($atts,$content) { // echo ‘test_sc’; $atts = shortcode_atts( array( ‘foo’ => ‘no foo’, ‘bar’ => ‘default bar’, ), $atts, ‘testsc’ ); // var_dump($atts); } add_shortcode(‘testsc’,’test_sc’); function test_shortcode_att_add($atts) { # this filter should only run … Read more