The codex explain, I think, very well the creation of shortcodes
http://codex.wordpress.org/Shortcode_API
A very basic shortcode
function foobar_func( $atts ){
return "foo and bar";
}
add_shortcode( 'foobar', 'foobar_func' );
To use it, you just need to [foobar]
The first parameter on add_shortcode
is the name of the shortcode
function bartag_func( $atts ) {
extract( shortcode_atts( array(
'foo' => 'something',
'bar' => 'something else',
), $atts ) );
return "foo = {$foo}";
}
add_shortcode( 'bartag', 'bartag_func' );
To use it, just use [bartag foo="foo-value"]
Related Posts:
- How to add a shortcode button to the TinyMCE editor?
- How to customise the output of the WP image gallery shortcode from a plugin?
- How to include code only on specific pages?
- Custom media upload content for inserting custom post shortcode
- Checking if an attribute exists in a shortcode
- how to include other plugins css files in a shortcode?
- What characters are allowed as a shortcode tag and how should they be sanitized?
- All shortcodes not working on custom theme
- enqueue script only if it is not already enqueue
- Shortcode output appears before post body [duplicate]
- Autogenerate wordpress shortcodes using array?
- PHP Deprecated: Non-static method should not be called statically
- How to parse nested shortcodes?
- Loading shortcode with ajax
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- Adding Custom Fields for Img in Posts
- How to call shortcode function directly and pass $atts
- How To Ignore a Filter On Applying Filter the Content In a Function
- Cannot strip JW Player shortcode?
- Shortcode display outside the div
- How to pass multiple values in shortcode?
- append stylesheet via shortcode
- Shortcode under a Shortcode Multiple times Possible?
- Pass $this to function nested in another public function of the same class
- change plugin shortcode function [closed]
- Calling function from within functions.php returns unwanted value
- plugin shortcodes not working on custom theme- unsure how to fix
- How to list all active and specific shortcodes in wordpress
- Dynamic HTML not displaying at respective place
- shortcode doesn’t work
- Plugin form unable to process
- Calling shortcode in wp_localize_script strips result
- Nested shortcodes
- WordPress shortcodes & performance
- Is it possible to make shortcodes NOT case sensitive?
- Short code for Venues
- do_shortcode() doesn’t work if shortcode contained in variable, works if shortcode passed as string
- Layout shop page: resize images and columns
- How to add inline css/js inside a shortcode
- How extend shortcode default values for a plugin?
- wordpress Shortocode running twice?
- Is there a function to search for a wildcard value when calling a shortcode?
- Shortcode in a blog post, footer and related products stop working
- shortcode which is introduced into entry the blog, and appears in side bar
- Call/Run a Mathematica (.m) Shell Script from WordPress Page/Blog
- How to display single arbitrary facebook post with a shortcode?
- Multiple level shortcodes
- Custom shortcode with dynamic rewrite
- Using “excerpt_more” filter for a specific post type
- Posting code inside the post instead of in the template file using shortcode
- Allow user to input shortcode into wordpress widget
- How to use shortcode of any plugin to show it visually where i want?
- apply_filters to content but ignore shortcodes
- Space in WordPress Attribute Causing Problems
- Why function hooked using object are executing at all time?
- Shortcode registered from a plugin not recognized
- How to Set Limit with WordPress Get Bookmarks Shortcode
- Strange get_the_* behavior with php 5.4
- How to load a plugin when doing an Ajax call? [duplicate]
- Trying to override/intercept a PhotoMosaic gallery link in WordPress using jQuery
- Strip shortcode from excerpt [duplicate]
- Need to change contact email depending where user is from
- Convert usernames listed by the Groups plugin shortcode to displayed names?
- Pulling RSS from site and display it in posts
- Trying to Understand Shortcodes.
- Creating Features List in WordPress Post
- Shortcode return is printing a 1 afterward
- How to use ‘Event Manager Shortcodes’ plugin via the php code? [closed]
- Embedding BitBucket Code in Posting
- Next and Previous Pagination button not displaying in WordPress
- Do shortcodes affect page indexing by search engines?
- do_shortcodes() isn’t working
- Any way to hook into WP after a page displays?
- WordPress shortcode plugin not working
- Integrate Razorpay quick payments plugin with contact form7 plugin
- WP Customer Reviews call short code on another page [closed]
- How to show in front End images using Visual Composer attach_images?
- Display HTML5 jQuery Audio Player On Front Page
- Shortcode returning specific content of a post
- Invalid argument supplied for foreach()
- Seo Problems in My meta Discription [closed]
- I am experiencing difficulty fulfilling client request
- cURL External API request displays content above other content on page
- Beginner question: Accessing js script in plugin
- Shortcode to do math with url variables
- How can I get the permalink of a page on which shortcode has been used
- Subtract Using GravityWP Count Plugin
- How to get URL param for pagination in shortcode?
- qTranslate‑X is not translating all shortcodes
- thumbnail_width not working in wordpress most popular post plugin
- Buffered output in chunks and shortcode – how do I achieve that?
- How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- Problem with a shortcode generating a error [closed]
- Display file contents within Plugin
- How do I edit text color for shortcode?
- correct way to enqueue js and css files for wordpress shortcode?
- How to get next day date of a specific day
- Custom Plugin not Displaying in the Website Production environment (Divi)
- Can I add two wordpress shortcode plugins in the same site (not the same page)?