Reputation: 5494
I have two shortcodes - the one get-product-tags-summary
calls get-product-tags
as seen below. I want to use the following schema:
echo '<ul class="brands-letter-list">';
echo '<li>';
do_shortcode('[get-product-tags letters="a,b,c,d,e"]');
echo '</li>';
echo '<li>';
do_shortcode('[get-product-tags letters="f,g,h,i,j"]');
echo '</li>';
echo '<li>';
do_shortcode('[get-product-tags letters="k,l,m,n,o,p,q"]');
echo '</li>';
echo '</ul>';
However this does not work correctly. The Output is:
<ul class="brands-letter-list">
<li></li>
</ul>
--- and here follows all the stuff from get-product-tags...
How can I solve this? It does not work correctly when called inside a function neither when I do it in the WP Admin post screen.
Thanks!
Upvotes: 1
Views: 57
Reputation: 381
With short codes you want to build your HTML then return it so WordPress can print it into the page at the appropriate location. If you echo it then its honestly anyone's guess where the output will show up since WordPress doesn't always do things in order and short codes are usually parsed before the rest of the page is sent.
Upvotes: 0
Reputation: 12689
do_shortcode()
returns the shortcode content, to display it use echo
.
echo do_shortcode('[get-product-tags letters="a,b,c,d,e"]');
Upvotes: 1