Wordpress Shortcode Loop Through Data And Send Current Looped Record To Other Shortcode In Custom PluginCompare Wordpress shortcode with $_GET in loop and return on te right positionWordpress shortcode looping dataWordpress Contact Form 7 customize HTML output of shortcodesHow can I process multiple image ids through a wordpress shortcode?Wordpress custom plugin to call total rows from database table and present in site using a shortcodeWordPress: wp_create_nonce() not creating a value inside custom pluginWordpress custom shortcode in page content not recognised by Yoast SEO pluginAppend HTML Using ShortcodeCreate a shortcode for a handmade plugin in WordpressAccessing Wrapping Wordpress Shortcode Content From Another Shortcode
I'm flying to France today and my passport expires in less than 2 months
Why doesn't H₄O²⁺ exist?
Does an object always see its latest internal state irrespective of thread?
Watching something be written to a file live with tail
Revoked SSL certificate
Why is consensus so controversial in Britain?
infared filters v nd
How do I deal with an unproductive colleague in a small company?
How old can references or sources in a thesis be?
"You are your self first supporter", a more proper way to say it
Unable to deploy metadata from Partner Developer scratch org because of extra fields
Client team has low performances and low technical skills: we always fix their work and now they stop collaborate with us. How to solve?
What defenses are there against being summoned by the Gate spell?
Horror movie about a virus at the prom; beginning and end are stylized as a cartoon
Roll the carpet
How much RAM could one put in a typical 80386 setup?
meaning of に in 本当に?
Did Shadowfax go to Valinor?
Approximately how much travel time was saved by the opening of the Suez Canal in 1869?
What are these boxed doors outside store fronts in New York?
Languages that we cannot (dis)prove to be Context-Free
Has there ever been an airliner design involving reducing generator load by installing solar panels?
NMaximize is not converging to a solution
Malformed Address '10.10.21.08/24', must be X.X.X.X/NN or
Wordpress Shortcode Loop Through Data And Send Current Looped Record To Other Shortcode In Custom Plugin
Compare Wordpress shortcode with $_GET in loop and return on te right positionWordpress shortcode looping dataWordpress Contact Form 7 customize HTML output of shortcodesHow can I process multiple image ids through a wordpress shortcode?Wordpress custom plugin to call total rows from database table and present in site using a shortcodeWordPress: wp_create_nonce() not creating a value inside custom pluginWordpress custom shortcode in page content not recognised by Yoast SEO pluginAppend HTML Using ShortcodeCreate a shortcode for a handmade plugin in WordpressAccessing Wrapping Wordpress Shortcode Content From Another Shortcode
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I am creating a plugin that currently returns a stores inventory from the database.
Right now I am simply outputting the raw text.
What I would like to do is output the data and have other shortcodes render the data.
For example:
[store_inventory]
[/store_inventory]
The above short code would return the following
array([0]=['item_name'='Juice', 'item_number' = '3dsj'], [1]=['item_name'='bread', 'item_number' = 'br3d']);
What I would like to do is have the store_inventory shortcode loop through the array instead of returning the raw array. And pass every individual returned value it loops through to another set of shortcodes so I can write the data into its own html.
My idea would look like this
[store_inventory] //This shortcode loops through the inventory array returned from the database
<div>
<p>[item_name]</p>//This shortcode returns current item_name being looped
<p>[item_number]</p>//This shortcode returns current item_number being looped
</div>
[/store_inventory]
I am just not sure how to handle looping through the array and passing the current data record from the array to the other two shortcodes.
Any help would be appreciated.
I know it would be easy to just spit out the HTML already formatted from the plugin but this would mean no front end editing via wordpress or version control via wordpress.
php wordpress
add a comment |
I am creating a plugin that currently returns a stores inventory from the database.
Right now I am simply outputting the raw text.
What I would like to do is output the data and have other shortcodes render the data.
For example:
[store_inventory]
[/store_inventory]
The above short code would return the following
array([0]=['item_name'='Juice', 'item_number' = '3dsj'], [1]=['item_name'='bread', 'item_number' = 'br3d']);
What I would like to do is have the store_inventory shortcode loop through the array instead of returning the raw array. And pass every individual returned value it loops through to another set of shortcodes so I can write the data into its own html.
My idea would look like this
[store_inventory] //This shortcode loops through the inventory array returned from the database
<div>
<p>[item_name]</p>//This shortcode returns current item_name being looped
<p>[item_number]</p>//This shortcode returns current item_number being looped
</div>
[/store_inventory]
I am just not sure how to handle looping through the array and passing the current data record from the array to the other two shortcodes.
Any help would be appreciated.
I know it would be easy to just spit out the HTML already formatted from the plugin but this would mean no front end editing via wordpress or version control via wordpress.
php wordpress
1
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14
add a comment |
I am creating a plugin that currently returns a stores inventory from the database.
Right now I am simply outputting the raw text.
What I would like to do is output the data and have other shortcodes render the data.
For example:
[store_inventory]
[/store_inventory]
The above short code would return the following
array([0]=['item_name'='Juice', 'item_number' = '3dsj'], [1]=['item_name'='bread', 'item_number' = 'br3d']);
What I would like to do is have the store_inventory shortcode loop through the array instead of returning the raw array. And pass every individual returned value it loops through to another set of shortcodes so I can write the data into its own html.
My idea would look like this
[store_inventory] //This shortcode loops through the inventory array returned from the database
<div>
<p>[item_name]</p>//This shortcode returns current item_name being looped
<p>[item_number]</p>//This shortcode returns current item_number being looped
</div>
[/store_inventory]
I am just not sure how to handle looping through the array and passing the current data record from the array to the other two shortcodes.
Any help would be appreciated.
I know it would be easy to just spit out the HTML already formatted from the plugin but this would mean no front end editing via wordpress or version control via wordpress.
php wordpress
I am creating a plugin that currently returns a stores inventory from the database.
Right now I am simply outputting the raw text.
What I would like to do is output the data and have other shortcodes render the data.
For example:
[store_inventory]
[/store_inventory]
The above short code would return the following
array([0]=['item_name'='Juice', 'item_number' = '3dsj'], [1]=['item_name'='bread', 'item_number' = 'br3d']);
What I would like to do is have the store_inventory shortcode loop through the array instead of returning the raw array. And pass every individual returned value it loops through to another set of shortcodes so I can write the data into its own html.
My idea would look like this
[store_inventory] //This shortcode loops through the inventory array returned from the database
<div>
<p>[item_name]</p>//This shortcode returns current item_name being looped
<p>[item_number]</p>//This shortcode returns current item_number being looped
</div>
[/store_inventory]
I am just not sure how to handle looping through the array and passing the current data record from the array to the other two shortcodes.
Any help would be appreciated.
I know it would be easy to just spit out the HTML already formatted from the plugin but this would mean no front end editing via wordpress or version control via wordpress.
php wordpress
php wordpress
asked Mar 21 at 22:53
Sebastian FloresSebastian Flores
33
33
1
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14
add a comment |
1
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14
1
1
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14
add a comment |
1 Answer
1
active
oldest
votes
You have to loop through each item in store_inventory
and pass the data in do_shortcode
.
I'm not sure how your store_inventory
shortcode looks like but see below example:
function story_inventory_loop( $atts )
extract( shortcode_atts( array(
//attributes
), $atts ) );
$output = '<div>';
$args = array(
'post_type' => 'post', //your post type
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$output .= '<p>'.
echo do_shortcode( '[item_name]' . get_the_title() . '[/item_name]' ).
'</p>'.
'<p>'.
echo do_shortcode( '[item_number]' . get_the_excerpt(). '[/item_number]' ).
'</p><!-- ends here -->';
endwhile;
wp_reset_query();
$output .= '</div>';
return $output;
add_shortcode('store_inventory', 'story_inventory_loop');
item_name
shortcode:
function item_name_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_name', 'item_name_shortcode' );
item_number
shortcode:
function item_number_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_number', 'item_number_shortcode' );
Hope this helps.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
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/3.0/"u003ecc by-sa 3.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%2fstackoverflow.com%2fquestions%2f55290420%2fwordpress-shortcode-loop-through-data-and-send-current-looped-record-to-other-sh%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You have to loop through each item in store_inventory
and pass the data in do_shortcode
.
I'm not sure how your store_inventory
shortcode looks like but see below example:
function story_inventory_loop( $atts )
extract( shortcode_atts( array(
//attributes
), $atts ) );
$output = '<div>';
$args = array(
'post_type' => 'post', //your post type
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$output .= '<p>'.
echo do_shortcode( '[item_name]' . get_the_title() . '[/item_name]' ).
'</p>'.
'<p>'.
echo do_shortcode( '[item_number]' . get_the_excerpt(). '[/item_number]' ).
'</p><!-- ends here -->';
endwhile;
wp_reset_query();
$output .= '</div>';
return $output;
add_shortcode('store_inventory', 'story_inventory_loop');
item_name
shortcode:
function item_name_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_name', 'item_name_shortcode' );
item_number
shortcode:
function item_number_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_number', 'item_number_shortcode' );
Hope this helps.
add a comment |
You have to loop through each item in store_inventory
and pass the data in do_shortcode
.
I'm not sure how your store_inventory
shortcode looks like but see below example:
function story_inventory_loop( $atts )
extract( shortcode_atts( array(
//attributes
), $atts ) );
$output = '<div>';
$args = array(
'post_type' => 'post', //your post type
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$output .= '<p>'.
echo do_shortcode( '[item_name]' . get_the_title() . '[/item_name]' ).
'</p>'.
'<p>'.
echo do_shortcode( '[item_number]' . get_the_excerpt(). '[/item_number]' ).
'</p><!-- ends here -->';
endwhile;
wp_reset_query();
$output .= '</div>';
return $output;
add_shortcode('store_inventory', 'story_inventory_loop');
item_name
shortcode:
function item_name_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_name', 'item_name_shortcode' );
item_number
shortcode:
function item_number_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_number', 'item_number_shortcode' );
Hope this helps.
add a comment |
You have to loop through each item in store_inventory
and pass the data in do_shortcode
.
I'm not sure how your store_inventory
shortcode looks like but see below example:
function story_inventory_loop( $atts )
extract( shortcode_atts( array(
//attributes
), $atts ) );
$output = '<div>';
$args = array(
'post_type' => 'post', //your post type
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$output .= '<p>'.
echo do_shortcode( '[item_name]' . get_the_title() . '[/item_name]' ).
'</p>'.
'<p>'.
echo do_shortcode( '[item_number]' . get_the_excerpt(). '[/item_number]' ).
'</p><!-- ends here -->';
endwhile;
wp_reset_query();
$output .= '</div>';
return $output;
add_shortcode('store_inventory', 'story_inventory_loop');
item_name
shortcode:
function item_name_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_name', 'item_name_shortcode' );
item_number
shortcode:
function item_number_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_number', 'item_number_shortcode' );
Hope this helps.
You have to loop through each item in store_inventory
and pass the data in do_shortcode
.
I'm not sure how your store_inventory
shortcode looks like but see below example:
function story_inventory_loop( $atts )
extract( shortcode_atts( array(
//attributes
), $atts ) );
$output = '<div>';
$args = array(
'post_type' => 'post', //your post type
'posts_per_page' => -1,
);
$query = new WP_Query( $args );
while ( $query->have_posts() ) : $query->the_post();
$output .= '<p>'.
echo do_shortcode( '[item_name]' . get_the_title() . '[/item_name]' ).
'</p>'.
'<p>'.
echo do_shortcode( '[item_number]' . get_the_excerpt(). '[/item_number]' ).
'</p><!-- ends here -->';
endwhile;
wp_reset_query();
$output .= '</div>';
return $output;
add_shortcode('store_inventory', 'story_inventory_loop');
item_name
shortcode:
function item_name_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_name', 'item_name_shortcode' );
item_number
shortcode:
function item_number_shortcode( $atts, $content = null )
return $content ;
add_shortcode( 'item_number', 'item_number_shortcode' );
Hope this helps.
answered Mar 22 at 6:09
designtocodedesigntocode
1,55441127
1,55441127
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f55290420%2fwordpress-shortcode-loop-through-data-and-send-current-looped-record-to-other-sh%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
1
Why are you wanting to use nested shortcodes rather than have the [store_inventory] shortcode handle looping through the data and generating the markup?
– Charlie Stanard
Mar 21 at 23:11
That is what is required by the frontend team I am working with. Because we are going to re-use this plugin on multiple sites and require having different html structures and styles. Doing it this way seems like it would give the most flexibility. Is there a more standard way to achieve this without having the loop generate the markup?
– Sebastian Flores
Mar 22 at 0:14