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
- WP_Query does not return the result even if the data is present in the database
- How to get next day date of a specific day
- Custom Plugin not Displaying in the Website Production environment (Divi)
- Plugin function inside custom plugin
- First plugin, problem with get_pages
- Flipping Book PHP Code? Any experience?
- wp-load.php redeclares classes
- plugins_url() works everywhere but wp_reqister_script()
- Hook into the rendering of a WordPress Template
- WPTouch – how to remove shortcodes or make shortcodes function
- How to make custom plugin run on demand?
- Replacing global wp_query
- creating a plug in that would tap into save/update action of posts [closed]
- Default taxonomy template in plugin, override in theme
- convert more tag to shortcode
- Can plugin2 uninstall plugin1 at the very beginning of plugin2’s installation?
- How to prevent plugins from sniffing/stealing other plugins’ options?
- adding a button to the media uploader
- Shortcode does not expand in Facebook like
- WordPress front end AJAX. Return 0 :?
- Hook for page Request?
- How to Resize the Custom Post Images?
- Custom Login Page — wp_signon Headers Already Sent?
- breadcrumb need to show all pages and subpages
- Widget’s container?
- custom uploader in the admin area
- Amazon.com intergration with WordPress?
- Best/Correct way to add an option to a category
- Plugin that provides the [edit] shortcode?