I am developing a plugin. But I am stuck when I add shortcode in my plugin. The problem is: When any shortcode attributes added on any post. What will be the settings value? means I am trying to say that

[demo speed=2000]

In that case my settings speed=500. So my question is that if anyone set shortcode attributes then it is needed to update the settings value? and If someone removes the shortcode attributes it will take settings value but already it is updated by attributes.

How can I check in jquery that shortcode attributes exist or not?


As you can see in the Shortcode API, there is no jquery involved in evaluating shortcodes. Shortcodes are evaluated on the server side, in PHP, not on the client side with jquery.

It is entirely up to you what you do with attributes in the shortcode. If the user writes something like:

[demo speed=2000]

you would exctract that as an array in your plugin like this

$args = array ('speed' -> 2000);

But there's no obligation to use $args in the plugins output. You could happily ignore it.

If you have a setting in your plugin that has the value of 'speed' as 500, you could decide to update it on evaluating the shortcode. In this way your site would 'remember' the value of the latest shortcode evaluation. Perhaps that's useful for your purpose.

Summing up, you can do anything you like with the attributes of a shortcode.

  • But I want to know different things such as speed is an attribute. It has settings value 2000 as default and it will effect jquery sliding speed.. but I am trouble when settings value and user defined shortcode attrs are different so what should I do? Can I skip settings value when users atts set? @cjbj – Roni Mar 29 '17 at 12:39
  • One last thing speed value uses at jquery such speed: 2000 – Roni Mar 29 '17 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.