According to Codex:
function shortcode_function_name( $atts ) {
$atts = shortcode_atts( array(
'attr1' => '',
), $atts, 'your-shortcode-name' );
return '<div id="'.$atts['attr1'].'">Your Predefined Content</div>';
}
add_shortcode( 'your-shortcode-name', 'shortcode_function_name' );
Adding [your-shortcode-name attr1="Value1"]
to the content of any post/page will give the following output <div id="Value1">Your Predefined Content</div>
.
Adding [your-shortcode-name attr1="Value1"]
to the content of any post/page will give the following output <div id="Value1">Your Predefined Content</div>
.
etc…
And you can deep by adding the predefined content inside the shortcode, this way you can always change the predefined content inside the shortcode as well.
Hope it helps!
Related Posts:
- Conditionally Loading JavaScript/CSS for Shortcodes
- Pass boolean value in shortcode
- Escaping quotes from shortcode attributes
- How to add ‘class’ attribute into shortcode [audio]?
- Automatically add this attribute to the gallery shortcode
- How to handle valueless attributes in shortcodes?
- Get multiple shortcode attribute values
- wpautop() when shortcode attributes are on new lines break args array
- Remove width and height attributes from [gallery] output
- Add attribute to existing Shortcode
- Shortcode displays only default attribute values
- Extending Shortcode attributes
- Remove HTML content if attribute is not set / variable attributes
- Global, network-wide shortcodes or text replace functions
- getting values from a shortcode with an include
- Why are Shortcodes Disabled in Widgets by Default?
- Add attribute to shortcode dynamically
- Replace / Remove Shortcode after 1st run / post
- Caption shortcodes not including caption as attribute
- Conditionally Loading JavaScript/CSS for Shortcodes
- Check if CTP category taxonomy is set in shortcode
- Passing variable in nested shortcodes
- How to use a nested shortcode to render the value of an attribute in parent shortcode
- Which wordpress function is the caption shortcode linked to?
- How to process a single attribute in a SQL request twice times?
- shortcode atts not working
- Second attribute of shortcode is not changing why?
- Replace custom gallery shortcode with default gallery shortcode
- Shortcode Attribute contains clone of all shortcode attributes
- Remove width and height attributes from [gallery] output
- how to have the gallery shortcode output one single UL list instead of several DL?
- WordPress transients for a shortcode
- Get post id shortcode
- How execute shortcode with javascript
- How to render complicated shortcodes
- My shortcode is not working in Contact Form 7 Message Body
- How to make this shortcode work for post content
- Get Shortcode Attributes
- How I make a shortcode for this code?
- Shortcode doesn’t work with classes
- Get shortcode from the content and display it in other place (in sidebar, for example)
- Adding shortcode to the main menu
- Executing a shortcode from a “normal” text/hyperlink
- Two different inner shortcode under shortcodes or multiple nesting of inner shortcodes
- Extra paragraph tags in an enclosing shortcode
- Order Woocommerce Products by Latest Reviewed
- $content not null in shortcode, even though it is self closing
- Create a shortcode that creates a form for users to edit their information
- How to split text text text into array
- Shortcode multiple values
- How do you stop a shortcode from firing in the editor?
- menu item to display the most recent post
- Documentation for adding a tinyMCE view for visual live preview of custom shortcode?
- How can I implement shortcode on click event
- Login form from shortcode doesn’t redirect after successful login
- How to list users by custom field?
- Form Shortcode not saving data to WP database
- Adding a class to shortcode API
- Pass data back to TinyMCE from Thickbox
- Forcing WP to embedd a video when using a shortcode
- Shortcode for output of wp_get_archives displays at top of post
- How to add “get_theme_mod” inside a shortcode?
- How to create shortcode to display perticular word from page title
- Shortcode is not returned correctly
- Echo HTML in custom shortcode
- How do I make a shortcode?
- Echoing Shortcode content inside the loop
- Short code inside the page not working in WordPress
- How can I list only custom shortcodes?
- Add inline style to pages where shortcode was used
- add new attributes into existing shortcodes
- Theme Icons not visible on http://domain.com, works on http://ipaddress
- How to pass an array as attribute of shortcode to work properly shortcode parser?
- Use atributes of shortcode in get template part
- Is there any way to set the Featured image in wordpress post editor, using a Getty images embed code
- How to use strip_shortcodes() from a spawned process?
- How to completely prevent WordPress from destroying/modifying my shortcode outputs?
- Term Description Echo or Return – display problems
- Same Shortcode not executing second time
- Check if Page=current user page via shortcode
- Is it inefficient to repeat a Shortcode 100 times on a page?
- tinymce custom button
- WordPress Payment link will not transform PHP vars into values
- Does a String Replacing script affect shortcode output?
- Shortcode for showing childpages
- How to create shortcode for auto login after registration
- How WordPress Displaying Shortcode In Post Content?
- Created a shortcode, using it twice (but differently) on a page but its just outputting the same one twice
- Access Shortcode in ajax code?
- WordPress Not rendering short code properly?
- Initialize add_action() for every copy of a specific shortcode
- Shortcodes that are created based on user input information
- Remove some tags from shortcodes output? Trying to fix autop
- do_shortcode & render custom field won’t work
- shortcodes inside shortcode to sum values
- is_mobile as shortcode
- How to attach sidebar to shortcode’s output?
- Shortcode append to the the_content()
- Wrapping a function in html tag and return?
- How to use multiple values in “Shortcode”? [closed]