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
- How to change a user’s password programatically
- How to delete custom taxonomy terms in plugin’s uninstall.php?
- how to include other plugins css files in a shortcode?
- Redirect to settings page after install
- What is the correct way for a theme to support plugin UIs?
- How does WordPress determine the primary plugin PHP file?
- translation does not work with text_domain
- Having separate plugins and themes folder for multi-site setup
- Many plugins making WordPress run slow by design?
- Add keywords meta to index.php page
- How can i get the post’s full html source by its ID?
- Force file download on plugin activation
- How can I add IP address to my post?
- add seperate suffix for low price and high price in woocommerce
- How to add/change (woocommerce) product tab icon
- Create Short code dynamically
- Is it possible to pin a post in second position from top
- How can I see $post object in frontend from functions.php?
- Move plugin pages from dashboard to front-end
- Update Plugin Without Overwriting Custom Settings
- How to create and use Custom hooks
- Custom Function for SEO by Yoast plugin
- Custom feed parameters / Template overriding
- Creating Event Builder Plugin [closed]
- Hook for single product thumbnail
- How to get custom setting from get_option and pass it in getEntityRecords in gutenberg block?
- WordPress hack code issue, help required