It’s just [link to= "https://wordpress.stackexchange.com/"]
.
This is a textbook example of why extract()
is bad. You can’t easily tell where variables are coming from. extract()
creates variables out of an array with the keys becoming the variable name. So this part:
extract(shortcode_atts(array(
"to" => 'http://net.tutsplus.com'
), $atts));
Is creating an array with a to
key, set to http://net.tutsplus.com
if it’s not defined in $atts
. Then it’s extract()
ed so that the to
key becomes $to
.
You should avoid using extract()
and just use the $atts
variable:
function link($atts, $content = null) {
$atts = shortcode_atts(array(
"to" => 'http://net.tutsplus.com'
), $atts);
return '<a href="'.$atts['to'].'">'.$content.'</a>';
}
Related Posts:
- How to add a shortcode button to the TinyMCE editor?
- Custom media upload content for inserting custom post shortcode
- Checking if an attribute exists in a shortcode
- 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]
- 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?
- Making a Template for a CPT created by a plugin
- creating html reusable blocks via shortcodes
- Single API call exposed via shortcode with params
- Creating shortcodes in plugin
- How to create a custom shortcode based on the layout?
- Inject HTML meta tag inside wordpress tag using add_shortcode
- Create shortcode to echo javascript
- Redirect to another page using contact form 7? [closed]
- 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
- 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?
- How to rewrite URL and get the values?
- 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
- Why is my shortcode not working?
- WP Plugin CSS not being applied to page
- Modify Plugin PHP Class in Child Theme – Correct Method
- Shortcode in a blog post, footer and related products stop working
- 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
- Any way to hook into WP after a page displays?
- Shortcode cannot parse attributes within double quotes. ” is becoming ” breaking my shortcode
- Display file contents within Plugin
- How to find out if option exists but is empty?
- Trigger a custom wordpress plugin with a linux cron
- update_meta_user difference in i:1 and b:1, how to write b:1
- Registration Form Validation in wordpress
- Add_rewrite_rule doesn’t add custom url in plugin
- Is this plugin being loaded before file.php, subsequently not allowing me to use certain functions?
- Shortcode in AJAX popup
- How do I write into a file (css)
- Next and/or previous post content
- How to periodically scrape and cache strings from remote txt files. – My First Plugin
- Is it possible to create Custom Post plug-in?
- why doesn’t this update part of this plugin work? it take me to nothing here page
- Using a custom plugin to capture input data via Ajax and PHP
- Display post lists in 2nd paragraph
- Is there a way to test that readme looks in other language before submitting translation?
- Insert content of a post into another
- Create tabs in admin options page from custom post type loop
- ob_start() combined with wp_query
- populating a form field with output from a custom plugin function
- How to activate a plugin on the activation of a theme?
- Custom Login Page — wp_signon Headers Already Sent?
- Is there a way to add custom endpoint to specific page only
- shortcode not return any thing in Gutnburg
- Add User Role: Pre-saved in User-Meta [SOLVED]
- How WordPress core manage the plugin installation
- Shortcode not working – quotes seems strange
- Post status doesn’t update to ‘future’ every time?
- Form Plugin for Api Requests which is used via Shortcode
- Echo out element to another page.
- count the number of views of a post excluding own views
- How To Create A File Archive in WordPress?
- How to set Google Analytics tracking code on WordPress plugin directory page?
- Problem with checked box on wp car manager plugin
- Create a link that calls our custom function in WordPress
- Load my Inline js footer area
- Remove action added in plugin class from theme
- wc_get_product_terms() throws “Notice: Undefined offset: 0”
- Woocommerce list variations that are added already to cart in Single Product
- How do I add a textarea (multirow) option to my WordPress plugin?
- Passing ajax variable to more than one wordpress plugin function
- Why isn’t my plugin seeing other classes?
- How to add jquery to my custom post type wp plugin
- Update post meta not working on wp_postmeta
- Redirect url in plugin to somewhere else?
- wp_insert_post_data filter to set category
- is there a way I can add or remove some plugin options?
- Embedding BitBucket Code in Posting
- Do shortcodes affect page indexing by search engines?
- What can I do to customize a widget provided with this plugin? from where have I to start?
- How can I save the selected page in the dropdown after anyone clicks on Save Changes?
- Wrong block appender button showing
- Uncaught Error: Cannot use object of type stdClass while showing the list using WP_List_Table
- plugin doesn’t retrieve data from database