add nested shortcode to php in WP_QUERY
-
I have a theme that uses an accordion that needs nested short codes. I’m trying to get it to work in my wp_query.
[av_toggle_container initial='0' mode='accordion' sort=''] [av_toggle title='Toggle 1' tags=''] Toggle Content goes here [/av_toggle] [av_toggle title='Toggle 2' tags=''] Toggle Content goes here [/av_toggle] [/av_toggle_container]There are short codes nested in shortcodes here, and the “av_toggle_container” i believe needs to be outside of my while portion of the query. How would i do that?
This is what i have right now:
if( $the_query->have_posts() ): ?> <?php echo do_shortcode( "[av_toggle_container initial='0' mode='accordion' sort='']"); while( $the_query->have_posts() ) : $the_query->the_post(); $toggletitle =get_the_title(); $togglecontent = get_the_content(); echo do_shortcode( "[av_toggle title='".$toggletitle."'tags='']".$togglecontent."[/av_toggle]"); endwhile; echo do_shortcode( '[/av_toggle_container]'); ?> <?php endif; ?> <?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
The topic ‘add nested shortcode to php in WP_QUERY’ is closed to new replies.