You need to capture the attributes that passed to a shortcode. You can do that like this
add_shortcode('testimonial', 'testimonial_shortcode_func');
function testimonial_shortcode_func( $atts ) {
$atts = shortcode_atts( array(
'style' => 'default_value_if_no_value_is_provided',
), $atts );
if( $atts['style'] == 'fancy' ) {
//do something
} else if ( $atts['style'] == 'something_else' ) {
//do something
}
//And so on
//finally return content, don't echo just return
}
Related Posts:
- Redirect to another page using contact form 7? [closed]
- Shortcode in a blog post, footer and related products stop working
- How to add a shortcode button to the TinyMCE editor?
- Custom media upload content for inserting custom post shortcode
- Creating two database tables via plugin
- Checking if an attribute exists in a shortcode
- Query Posts by Custom Field ‘Price’
- enqueue script only if it is not already enqueue
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- How To Ignore a Filter On Applying Filter the Content In a Function
- Shortcode display outside the div
- Pass $this to function nested in another public function of the same class
- shortcode doesn’t work
- How to add inline css/js inside a shortcode
- Only execute jQuery function(on document ready) on the page has shortcode from plugin [duplicate]
- How use %like% in sql statement wordpress
- Accessing GET variable named ‘error’
- WP_Query ordering numbers as letters
- Demystifying and understanding shortcode nomenclature
- Any Short code Availble for Get Post List With Thumbnail Plugin?
- Where to call add_shortcode function in WordPress Plugin Boilerplate?
- Input with spaces in Shortcode attributes overwritten by defaults
- Allow users of my plugin to define their own shortcode rather than use mine?
- switched from query_posts to WP_query, not working now?
- AJAX search posts and pages
- Making a Template for a CPT created by a plugin
- creating html reusable blocks via shortcodes
- Single API call exposed via shortcode with params
- Insert content of a post into another
- how to use in custom single.php template using php?
- Creating shortcodes in plugin
- Inject HTML meta tag inside wordpress tag using add_shortcode
- Create shortcode to echo javascript
- Namespaced shortcode?
- How can I run a custom shortcode function on a live site and only run if the viewer is a specific machine?
- Why am I unable to load scripts in head in plugin?
- How to add a dvi tag to a shortcode then change a generated text using jQuery
- Return multiple values in a shortcode attribute
- IF condition based on wp_remote_get output
- Shortcode Attributes to Return different $_POST
- How to use template inside plugin shortcode with variables for big HTML code
- strange shortcode error: does shortcodes requires any dependency?
- Loop returns the current page’s permalink and guid instead of the post in the loop
- How to rewrite URL and get the values?
- Delete data from custom table when deleting a post
- How to Join wp_posts & wp_postmeta table using custom query
- Thumbnail image doesn’t show up in Shortcode output
- list of custom post by custom field in frontend
- Shortcode do not return the right data in post
- How to call function in WordPress on button click?
- Hide content for specific users with id
- adding dynamic/multiple slug values in ‘option_none_value’
- Why is my shortcode not working?
- Performance considerations – postmeta table versus new table for custom posts with foreign keys?
- How to pass multiple custom fields as shortcode’s parameters
- Checkbox field that add a subscription product and change prices of other products in checkout and cart page
- How to use information from the database in the front-end?
- WP Plugin CSS not being applied to page
- Modify Plugin PHP Class in Child Theme – Correct Method
- How to insert variable which contain array value in wp_options table?
- shortcode which is introduced into entry the blog, and appears in side bar
- Why function hooked using object are executing at all time?
- Shortcode registered from a plugin not recognized
- WP-Snap too slow (caused by WP_Query?)
- WordPress Meta Query: Relation is not working correctly
- Making a Custom Post Type Publish Loop
- Checking url from plugin [duplicate]
- Any way to hook into WP after a page displays?
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- Accessing Correct Database to Create REST API Endpoint
- Display file contents within Plugin
- How do I unlock a post programmatically?
- How to parse nested shortcodes?
- How to extract images of post and pages excluding header and logo image in wordpress?
- Dynamic HTML not displaying at respective place
- merging an array to an existing array using add_filter
- Is it possible to set up multistore in Woocommerce? [closed]
- How to export post 2 posts WordPress plugin data [closed]
- Adding Font Awesome to WP Plugin
- Deactivate JS Script in Plugin Shortcode
- Basic question about accessing scripts in my plugin
- Automatically download, install and activate plugins that my plugin depends, how?
- WordPress SVN UTF-8 issue
- Asynchronous request in wordpress
- change or add css to theme from plugin
- Displaying data from another database
- Every time I de-activate a custom plugin, the site encounters a critical error
- How to make sure settings are not lost when plugin is updated?
- How Can i import plugin option?
- How to override any plugin file in the child theme
- Define global variable in theme file and call that variable in plugin file
- Using Shortcode Result In Custom HTML Block (Using Google Sheet JQuery Result As NumScroller data-max)
- How do I stop plugins and themes from getting updated in a new plugin?
- plugin not hooking to my custom hook
- Populate select option with JSON file
- How to save default values into an option and delete those upon actvation and deactivation in wordpress?
- How to Add Jquery FullCalendar in wp plugin in admin
- Ajax, jQuery and WordPress
- Unable to show 4 products in a row
- WordPress check box unchecked on null value ternary operator [plugin development]