Creating a shortcode based on users preferences

Theory It might have been hard to word for you, but is actually quite clear what you are trying to accomplish. A shortcode is a good way to insert dynamic content into a page (or post), the point at which your idea fails is the notion of a “dynamic shortcode”. Use the shortcode to insert … Read more

How to create a shortcode for embedding pdf in iframe?

It depends on how you want the pdfs added but this should probably be a cover all: function embed_pdf_files( $atts, $content = null ){ //add default attributes here. $defaults = array( //’width’ => ‘100%’, //’height’ => ‘1000’ ); //This overwrites defaults with the attributes in shortcode $a = shortcode_atts( $defaults, $atts ); $src = $a[‘src’]; … Read more

Shortcode API: How to get name that matched shortcode RegEx?

I think you just forgot to run the shortcodes [foo a=”b”] and [bar a=”c”] through the do_shortcode filter: do_shortcode( ‘[foo a=”b”] [bar a=”c”]’ ) The output of the_content() is filtered through the do_shortcode, so you can just add it into your editor instead. Running your code I get the following output for the $arguments dump: … Read more

Shortcodes Keep Wrapping in

Try https://wordpress.org/plugins/shortcode-empty-paragraph-fix/ It basically removes any p-tags before and after [ or ], before rendering the content. So the output of your shortcodes won’t be wrapped in p-tags

Overriding shortcode $atts for featured products

Alright I want to post this here because of the title of your question. There is a way to change shortcode attributes, but it will also rely on what the developer of the plugin has done. When a plugin is developed with a shortcode there is an option to use the shortcode_atts() function. This happens … Read more