Shortcode under a Shortcode Multiple times Possible?Hide/disable sidebar using shortcode?Shortcode returns values in the wrong orderHow to use author meta in shortcode?esc_attr not working in shortcodeHow to add a dvi tag to a shortcode then change a generated text using jQueryPHP Running On CMS Side of WordpressShortcode to do math with url variablescustom post type category count shortcode
When would open interest equal trading volume?
Can Brexit be undone in an emergency?
Who are the people reviewing far more papers than they're submitting for review?
Should I inform my future product owner that there is a good chance that a team member will leave the company soon?
How do you determine which representation of a function to use for Newton's method?
What exactly is a web font, and what does converting to one involve?
How to convey to the people around me that I want to disengage myself from constant giving?
Strength of Female Chimpanzees vs. Male Chimpanzees?
Can a Druid Wild Shaped as a horse use Horseshoes of Speed?
MySQL - How to check for a value in all columns
Is it safe to unplug a blinking USB drive after 'safely' ejecting it?
Can I separate garlic into cloves for storage?
What the did the controller say during my approach to land (audio clip)?
(How long) Should I indulge my new co-workers?
Is a global DNS record a security risk for phpMyAdmin?
Does rpcpassword need to be non-obvious in bitcoind?
Account creation and log-in system
Carroll's interpretation of 1-forms
Why does Canada require a minimum rate of climb for ultralights of 300 ft/min?
Is this adjustment to the Lucky feat underpowered?
Cemented carbide swords - worth it?
Do household ovens ventilate heat to the outdoors?
Problem of Induction: Dissolved
Does Mage Hand give away the caster's position?
Shortcode under a Shortcode Multiple times Possible?
Hide/disable sidebar using shortcode?Shortcode returns values in the wrong orderHow to use author meta in shortcode?esc_attr not working in shortcodeHow to add a dvi tag to a shortcode then change a generated text using jQueryPHP Running On CMS Side of WordpressShortcode to do math with url variablescustom post type category count shortcode
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
[shortcode]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[/shortcode]
Based on the need for a shortcode an HTML parts needs to be repeated based on user/admin inputs. I have presented a format. Is the above a possibility?
Can a shortcode be published within a shortcode multiple times?
Further explanation of the situation Future reader may find it helpful→ This is the edifice of an HTML (Hypothetical example)
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<p>Answer</p>
</li>
</ul>
</div>
</div>
</div>
This part is repetitive and Inner shortcode →
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<h3>Question</h3>
</li>
I think the code for the external shortcode will be written like this →
function external_shortcode()
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<!-- This is the place where I want the inner shortcode many time -->
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Code for the Inner shortcode →
function internal_shortcode($atts, $content = null)
$data = [
'title' => 'Some heading text goes here.',
];
$values = shortcode_atts($data, $atts);
ob_start();
?>
<li class="question">
<h3><?php echo esc_attr($values['title']); ?></h3>
</li>
<li class="answer">
<p><?php echo $content; ?></p>
</li>
<?php
return ob_get_clean();
add_shortcode( 'shortcode1', 'internal_shortcode' );
plugins functions shortcode
add a comment
|
[shortcode]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[/shortcode]
Based on the need for a shortcode an HTML parts needs to be repeated based on user/admin inputs. I have presented a format. Is the above a possibility?
Can a shortcode be published within a shortcode multiple times?
Further explanation of the situation Future reader may find it helpful→ This is the edifice of an HTML (Hypothetical example)
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<p>Answer</p>
</li>
</ul>
</div>
</div>
</div>
This part is repetitive and Inner shortcode →
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<h3>Question</h3>
</li>
I think the code for the external shortcode will be written like this →
function external_shortcode()
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<!-- This is the place where I want the inner shortcode many time -->
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Code for the Inner shortcode →
function internal_shortcode($atts, $content = null)
$data = [
'title' => 'Some heading text goes here.',
];
$values = shortcode_atts($data, $atts);
ob_start();
?>
<li class="question">
<h3><?php echo esc_attr($values['title']); ?></h3>
</li>
<li class="answer">
<p><?php echo $content; ?></p>
</li>
<?php
return ob_get_clean();
add_shortcode( 'shortcode1', 'internal_shortcode' );
plugins functions shortcode
add a comment
|
[shortcode]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[/shortcode]
Based on the need for a shortcode an HTML parts needs to be repeated based on user/admin inputs. I have presented a format. Is the above a possibility?
Can a shortcode be published within a shortcode multiple times?
Further explanation of the situation Future reader may find it helpful→ This is the edifice of an HTML (Hypothetical example)
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<p>Answer</p>
</li>
</ul>
</div>
</div>
</div>
This part is repetitive and Inner shortcode →
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<h3>Question</h3>
</li>
I think the code for the external shortcode will be written like this →
function external_shortcode()
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<!-- This is the place where I want the inner shortcode many time -->
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Code for the Inner shortcode →
function internal_shortcode($atts, $content = null)
$data = [
'title' => 'Some heading text goes here.',
];
$values = shortcode_atts($data, $atts);
ob_start();
?>
<li class="question">
<h3><?php echo esc_attr($values['title']); ?></h3>
</li>
<li class="answer">
<p><?php echo $content; ?></p>
</li>
<?php
return ob_get_clean();
add_shortcode( 'shortcode1', 'internal_shortcode' );
plugins functions shortcode
[shortcode]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[shortcode1 title="variable text"] Some text[/shortcode1]
[/shortcode]
Based on the need for a shortcode an HTML parts needs to be repeated based on user/admin inputs. I have presented a format. Is the above a possibility?
Can a shortcode be published within a shortcode multiple times?
Further explanation of the situation Future reader may find it helpful→ This is the edifice of an HTML (Hypothetical example)
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<p>Answer</p>
</li>
</ul>
</div>
</div>
</div>
This part is repetitive and Inner shortcode →
<li class="question">
<h3>Question</h3>
</li>
<li class="answer">
<h3>Question</h3>
</li>
I think the code for the external shortcode will be written like this →
function external_shortcode()
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<!-- This is the place where I want the inner shortcode many time -->
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Code for the Inner shortcode →
function internal_shortcode($atts, $content = null)
$data = [
'title' => 'Some heading text goes here.',
];
$values = shortcode_atts($data, $atts);
ob_start();
?>
<li class="question">
<h3><?php echo esc_attr($values['title']); ?></h3>
</li>
<li class="answer">
<p><?php echo $content; ?></p>
</li>
<?php
return ob_get_clean();
add_shortcode( 'shortcode1', 'internal_shortcode' );
plugins functions shortcode
plugins functions shortcode
edited 6 hours ago
The WP Intermediate
asked 8 hours ago
The WP IntermediateThe WP Intermediate
8812 gold badges11 silver badges31 bronze badges
8812 gold badges11 silver badges31 bronze badges
add a comment
|
add a comment
|
2 Answers
2
active
oldest
votes
Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within.
So, for example, if your [shortcode]
does something like
function outer_shortcode($content = null)
return '<div>' . $content . '</div>';
just be sure to update it to parse the content for other shortcodes:
function outer_shortcode($content = null)
return '<div>' . do_shortcode($content) . '</div>';
You can then nest however many duplicate shortcodes as you like inside.
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
add a comment
|
Using @WebElaine's example, all you need is to add the do_shortcode($content) to your current code:
// use both parameters in your function declaration, even if you will ignore the $atts
function external_shortcode($atts, $content)
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<?php
// Using do_shortcode will cause Wordpress to output your inner shortcodes.
do_shortcode($content);
?>
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Yes, I got it sir.
– The WP Intermediate
6 hours ago
add a comment
|
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "110"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f348408%2fshortcode-under-a-shortcode-multiple-times-possible%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within.
So, for example, if your [shortcode]
does something like
function outer_shortcode($content = null)
return '<div>' . $content . '</div>';
just be sure to update it to parse the content for other shortcodes:
function outer_shortcode($content = null)
return '<div>' . do_shortcode($content) . '</div>';
You can then nest however many duplicate shortcodes as you like inside.
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
add a comment
|
Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within.
So, for example, if your [shortcode]
does something like
function outer_shortcode($content = null)
return '<div>' . $content . '</div>';
just be sure to update it to parse the content for other shortcodes:
function outer_shortcode($content = null)
return '<div>' . do_shortcode($content) . '</div>';
You can then nest however many duplicate shortcodes as you like inside.
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
add a comment
|
Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within.
So, for example, if your [shortcode]
does something like
function outer_shortcode($content = null)
return '<div>' . $content . '</div>';
just be sure to update it to parse the content for other shortcodes:
function outer_shortcode($content = null)
return '<div>' . do_shortcode($content) . '</div>';
You can then nest however many duplicate shortcodes as you like inside.
Yes, you can include a shortcode however many times you like, inside a shortcode. Just make sure you set up the parent shortcode to parse shortcodes nested within.
So, for example, if your [shortcode]
does something like
function outer_shortcode($content = null)
return '<div>' . $content . '</div>';
just be sure to update it to parse the content for other shortcodes:
function outer_shortcode($content = null)
return '<div>' . do_shortcode($content) . '</div>';
You can then nest however many duplicate shortcodes as you like inside.
answered 8 hours ago
WebElaineWebElaine
5,6731 gold badge8 silver badges18 bronze badges
5,6731 gold badge8 silver badges18 bronze badges
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
add a comment
|
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
It worked. Thanks a ton.
– The WP Intermediate
6 hours ago
add a comment
|
Using @WebElaine's example, all you need is to add the do_shortcode($content) to your current code:
// use both parameters in your function declaration, even if you will ignore the $atts
function external_shortcode($atts, $content)
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<?php
// Using do_shortcode will cause Wordpress to output your inner shortcodes.
do_shortcode($content);
?>
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Yes, I got it sir.
– The WP Intermediate
6 hours ago
add a comment
|
Using @WebElaine's example, all you need is to add the do_shortcode($content) to your current code:
// use both parameters in your function declaration, even if you will ignore the $atts
function external_shortcode($atts, $content)
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<?php
// Using do_shortcode will cause Wordpress to output your inner shortcodes.
do_shortcode($content);
?>
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Yes, I got it sir.
– The WP Intermediate
6 hours ago
add a comment
|
Using @WebElaine's example, all you need is to add the do_shortcode($content) to your current code:
// use both parameters in your function declaration, even if you will ignore the $atts
function external_shortcode($atts, $content)
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<?php
// Using do_shortcode will cause Wordpress to output your inner shortcodes.
do_shortcode($content);
?>
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
Using @WebElaine's example, all you need is to add the do_shortcode($content) to your current code:
// use both parameters in your function declaration, even if you will ignore the $atts
function external_shortcode($atts, $content)
ob_start();
?>
<div class="classone">
<div class="classtwo">
<div class="classthree">
<ul class="four">
<?php
// Using do_shortcode will cause Wordpress to output your inner shortcodes.
do_shortcode($content);
?>
</ul>
</div>
</div>
</div>
<?php
return ob_get_clean();
add_shortcode( 'shortcode', 'external_shortcode' );
answered 6 hours ago
Mike BaxterMike Baxter
6514 silver badges9 bronze badges
6514 silver badges9 bronze badges
Yes, I got it sir.
– The WP Intermediate
6 hours ago
add a comment
|
Yes, I got it sir.
– The WP Intermediate
6 hours ago
Yes, I got it sir.
– The WP Intermediate
6 hours ago
Yes, I got it sir.
– The WP Intermediate
6 hours ago
add a comment
|
Thanks for contributing an answer to WordPress Development Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
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
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fwordpress.stackexchange.com%2fquestions%2f348408%2fshortcode-under-a-shortcode-multiple-times-possible%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
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
Required, but never shown
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
Required, but never shown
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
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown