Collect all of the loop’s output in a variable, wrap it in the accordion shortcode, then pass that through do_shortcode:
$output="";
if ( have_posts() ) :
while ( have_posts() ) : the_post();
$output .= '<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">';
$output .= do_shortcode('[su_spoiler title="'.get_the_title().'" open="no" style="default" icon="plus" anchor="" class=""]'.get_the_content().'[/su_spoiler]');
$output .= '</div>';
endwhile;
else :
$output = wpautop( 'Sorry, no posts were found' );
endif;
echo do_shortcode( '[su_accordion]' . $output . '[/su_accordion]' );
I’ve tested this with a couple of enclosing Shortcodes and got the expected output.
Related Posts:
- Split Content and Gallery
- How to return loop contents
- How do I get the attributes of a short code from a post?
- Return vs Echo Shortcode
- as a shortcode within the loop?
- What are the disadvantages of using global variable?
- Displaying terms based on loop posts?
- Missing image in gallery shortcode in custom feed
- Shortcode with a foreach and arguments
- Output loop leveraged shortcode twice on one page
- Custom Loop Using Shortcode in Custom Page Template
- Shortcode in posts called by ajax is not working
- Trying to get property of non-object in shortocde
- WordPress shortcode in content, output in sidebar?
- Query posts only with actual text content (not including shortcode or images)
- How to put a block of code between [shortcode][/shortcode] in do_shortcode()?
- How can I pass additional params to a shortcode while in a loop?
- Get a Post Loop based on Logged in User information into a Shortcode
- How to add pagination in Terms
- Split Content and Gallery
- Shortcode for pulling specific Post Title outside loop when ID is passed in
- Have multiple loops on a page appear after/between page content
- Using shortcode within shortcode with dynamic variable
- How wp maps urls into files
- WordPress category & taxonomy loop with pagination
- Changing behavior of the loop twice in one page
- Show scheduled posts in archive page
- post__in – Placing content from a foreach loop inside of an array
- loop query exclude meta_key with meta_value
- “Blog pages show at most” in The Loop
- wp_insert_posts Fatal error: Maximum function nesting level of ‘100’ reached, aborting!
- Post Loop not Returning Permalink
- Displaying child page content of a certain parent
- Pagination adding extra posts only on page 2
- Custom page template
- Get posts that matches specific terms of multiple custom taxonomies
- add_filter() doesn’t work in loop
- Function to show only first instance of shortcode
- The Loop in Static Page
- Content/Excerpt length control for a specific loop?
- Why we use if with while loop?
- Loop posts only excluding first post
- Custom search form to display users only
- Displaying the last page of posts
- How to get_posts where ‘menu_order’ is more than 0/zero?
- WordPress Redirects on Install
- How to load all pages into one page with their templates
- How to return only one instance of each, from the entire loop
- Combining action and filter?
- Calling & display certain product category loop and pagination on the homepage
- Insert content of a post into another
- Detect if current page is front page within custom query
- Blog’s post count cause irratic behavior
- Sanitize Custom Field Value in Meta Query
- Default ‘post’ post type archive slug?
- show random image in loop if image is not set
- Get Page content to displayin Bootstrap Modal
- Pagination – works on local but not live dev!
- need help looping add_action in wp
- Does WordPress Loop have a function like Shopify’s cycle?
- Combine the results of two loops [closed]
- How to display pending posts on the homepage only for editors
- How can I improve the performance of this query_posts loop?
- Add leading zero to current post display [closed]
- Output meta into arrays
- the_post() is printing titles in page footer
- Adding div after every two post on main loop! Why will first post not get counted?
- Moving wordpress to different url/server creates redirect loop
- Pulling in featured image into default recent posts widget
- Modify loop output for a specific list of categories
- Print the whole page?
- Pagination for two loops
- Loop info in jquery Tabs – loop into a variable?
- Thumbnail Image Rounded Corners w CSS (or any other good method)
- Several loops in sidebar issues
- Adding $args to wp_schedule_event() causes hook to add infinitely to WP Cron
- $post is undefined in wordpress loop [ajax]
- How to add a shortcode function that returns the taxonomy slug of the actual post within the loop
- Insert content above an embedded video inside Wordress’ php the_content
- Loop with custom posts, to include information from different custom post type
- the loop printing post in one grid
- Check value of post meta within IF statement
- My WordPress installation doesn’t load correct template
- Work arounds for conditional checks inside the loop in search.php?
- Get Sticky User in user loop based on user role
- Popular posts with Varnish ESI
- Querying posts from only one category and exluding the latest post
- WP update_post_meta link loop
- How do I aproach this?(for sale, for lease, sold->move something from a category to another)
- How to fix pagination for custom loops?
- query_posts ignores the argument
- Need some help with “the_widget()” function
- Conditional Check in The Loop’s Parameters
- show posts from one category with comments only
- Exclude Authors based off date of last post
- Loop from another WP site onto mine
- Having issue with WordPress loop
- Wrap every 2 divs in row – for each loop [closed]
- How to add class to the last image of the last post in a loop
- Use Base-URL with Query-Loop