Shortcode attribute value with dash (hyphen)
Clash Royale CLAN TAG#URR8PPP
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;
up vote
3
down vote
favorite
Is it safe to use hyphen in shortcode attribute value?
For example:
[foo something="fo-bar"]
shortcode
add a comment |Â
up vote
3
down vote
favorite
Is it safe to use hyphen in shortcode attribute value?
For example:
[foo something="fo-bar"]
shortcode
1
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28
add a comment |Â
up vote
3
down vote
favorite
up vote
3
down vote
favorite
Is it safe to use hyphen in shortcode attribute value?
For example:
[foo something="fo-bar"]
shortcode
Is it safe to use hyphen in shortcode attribute value?
For example:
[foo something="fo-bar"]
shortcode
asked Aug 20 at 14:01
Toniq
171111
171111
1
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28
add a comment |Â
1
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28
1
1
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
-2
down vote
accepted
It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.
Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):
[tag]
[tag-a]
It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.
To avoid this, use an underscore or simply no separator:
[tag_a]
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
add a comment |Â
up vote
7
down vote
tl;dr; Dash (hyphen)
-
is safe to use within shortcode attribute values.
Rules for Shortcode attribute values:
For shortcode attribute values, anything other than the following four is usually fine:
- There shouldn't be any square brackets
[
or]
, e.g.[foo bar='baa]z']
- There shouldn't be single quote within single quote, e.g.
[foo bar='baa'z']
- There shouldn't be double quote within double quote, e.g.
[foo bar="baa"z"]
- Back slash
will be escaped.
So the following example shortcode attribute values are just fine:
// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']
Quote from codex:
Attribute values must never contain the following characters:
Square braces:
[ ]
Quotes:
" '
Unquoted values also must never contain spaces.
HTML characters
<
and>
have only limited support in attributes.
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.
Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.
The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:
No-break space:
xC2xA0
Zero-width space:
xE2x80x8B
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
-2
down vote
accepted
It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.
Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):
[tag]
[tag-a]
It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.
To avoid this, use an underscore or simply no separator:
[tag_a]
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
add a comment |Â
up vote
-2
down vote
accepted
It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.
Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):
[tag]
[tag-a]
It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.
To avoid this, use an underscore or simply no separator:
[tag_a]
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
add a comment |Â
up vote
-2
down vote
accepted
up vote
-2
down vote
accepted
It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.
Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):
[tag]
[tag-a]
It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.
To avoid this, use an underscore or simply no separator:
[tag_a]
It's safe, you won't have any problem using it, the only caution about Hyphens and Shortcodes comes from the Codex.
Take caution when using hyphens in the name of your shortcodes. In the
following instance WordPress may see the second opening shortcode as
equivalent to the first (basically WordPress sees the first part
before the hyphen):
[tag]
[tag-a]
It all depends on which shortcode is defined first. If you are going
to use hyphens then define the shortest shortcode first.
To avoid this, use an underscore or simply no separator:
[tag_a]
answered Aug 20 at 14:07


Castiblanco
1,73221020
1,73221020
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
add a comment |Â
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
5
5
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
Please note that the question is really about attribute values, not about shortcode naming. The OP accepted this answer, but it may confuse future visitors.
– Fayaz
Aug 20 at 15:30
2
2
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
@Fayaz Thanks for the comment. I would have missed that.
– fredsbend
Aug 20 at 22:36
add a comment |Â
up vote
7
down vote
tl;dr; Dash (hyphen)
-
is safe to use within shortcode attribute values.
Rules for Shortcode attribute values:
For shortcode attribute values, anything other than the following four is usually fine:
- There shouldn't be any square brackets
[
or]
, e.g.[foo bar='baa]z']
- There shouldn't be single quote within single quote, e.g.
[foo bar='baa'z']
- There shouldn't be double quote within double quote, e.g.
[foo bar="baa"z"]
- Back slash
will be escaped.
So the following example shortcode attribute values are just fine:
// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']
Quote from codex:
Attribute values must never contain the following characters:
Square braces:
[ ]
Quotes:
" '
Unquoted values also must never contain spaces.
HTML characters
<
and>
have only limited support in attributes.
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.
Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.
The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:
No-break space:
xC2xA0
Zero-width space:
xE2x80x8B
add a comment |Â
up vote
7
down vote
tl;dr; Dash (hyphen)
-
is safe to use within shortcode attribute values.
Rules for Shortcode attribute values:
For shortcode attribute values, anything other than the following four is usually fine:
- There shouldn't be any square brackets
[
or]
, e.g.[foo bar='baa]z']
- There shouldn't be single quote within single quote, e.g.
[foo bar='baa'z']
- There shouldn't be double quote within double quote, e.g.
[foo bar="baa"z"]
- Back slash
will be escaped.
So the following example shortcode attribute values are just fine:
// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']
Quote from codex:
Attribute values must never contain the following characters:
Square braces:
[ ]
Quotes:
" '
Unquoted values also must never contain spaces.
HTML characters
<
and>
have only limited support in attributes.
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.
Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.
The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:
No-break space:
xC2xA0
Zero-width space:
xE2x80x8B
add a comment |Â
up vote
7
down vote
up vote
7
down vote
tl;dr; Dash (hyphen)
-
is safe to use within shortcode attribute values.
Rules for Shortcode attribute values:
For shortcode attribute values, anything other than the following four is usually fine:
- There shouldn't be any square brackets
[
or]
, e.g.[foo bar='baa]z']
- There shouldn't be single quote within single quote, e.g.
[foo bar='baa'z']
- There shouldn't be double quote within double quote, e.g.
[foo bar="baa"z"]
- Back slash
will be escaped.
So the following example shortcode attribute values are just fine:
// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']
Quote from codex:
Attribute values must never contain the following characters:
Square braces:
[ ]
Quotes:
" '
Unquoted values also must never contain spaces.
HTML characters
<
and>
have only limited support in attributes.
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.
Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.
The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:
No-break space:
xC2xA0
Zero-width space:
xE2x80x8B
tl;dr; Dash (hyphen)
-
is safe to use within shortcode attribute values.
Rules for Shortcode attribute values:
For shortcode attribute values, anything other than the following four is usually fine:
- There shouldn't be any square brackets
[
or]
, e.g.[foo bar='baa]z']
- There shouldn't be single quote within single quote, e.g.
[foo bar='baa'z']
- There shouldn't be double quote within double quote, e.g.
[foo bar="baa"z"]
- Back slash
will be escaped.
So the following example shortcode attribute values are just fine:
// dash or hyphen is fine
[foo bar='baa-z']
// Double quote within single quote is fine
[foo bar='baa"z']
// single quote within double quote is fine
[foo bar="baa'z"]
// space is fine
[foo bar='baa z']
// use double back slash to get single back slash
[foo bar='baa\z']
Quote from codex:
Attribute values must never contain the following characters:
Square braces:
[ ]
Quotes:
" '
Unquoted values also must never contain spaces.
HTML characters
<
and>
have only limited support in attributes.
The recommended method of escaping special characters in shortcode attributes is HTML encoding. Most importantly, any user input appearing in a shortcode attribute must be escaped or stripped of special characters.
Note that double quotes are allowed inside of single-quoted values and vice versa, however this is not recommended when dealing with user input.
The following characters, if they are not escaped within an attribute value, will be automatically stripped and converted to spaces:
No-break space:
xC2xA0
Zero-width space:
xE2x80x8B
edited Aug 20 at 16:24
answered Aug 20 at 15:26


Fayaz
5,12811228
5,12811228
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f311956%2fshortcode-attribute-value-with-dash-hyphen%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
1
You asked about shortcode attribute values, however, you've accepted the answer that's about shortcode tag or name. Am I missing something?
– Fayaz
Aug 20 at 15:28