Plugin Author
Vova
(@gn_themes)
Thread Starter
raidje
(@raidje)
Yes !! Thank you Vladimir !
it’s exactly what i needed. I had searched in the documentation of your pluggin but i did not find.
Thank you for your quick response, your help and your pluggin.
Raidje
Thread Starter
raidje
(@raidje)
i try to do that : get posts of a category inside the spoiler
$content = '<?php if( have_posts() ) : ?><?php wpbf_archive_header(); ?><?php do_action( "wpbf_before_loop" ); ?><?php while ( have_posts() ) : the_post(); ?><?php get_template_part( "inc/template-parts/article" ); ?><?php endwhile; ?><?php do_action( "wpbf_after_loop" ); ?><?php else : ?><?php get_template_part( "inc/template-parts/article-none" ); ?><?php endif; ?>';
$my_shortcode = '[su_spoiler title="Informations d\'Occitanie" open="yes" style="default" icon="plus" anchor="" class=""]' . $content . '[/su_spoiler]';
the spoiler works but it returns no content
Plugin Author
Vova
(@gn_themes)
Hi Raidje,
you have invalid code on the first line. Your $content variable shouldn’t work, and it doesn’t. To be frank, I’m surprised you don’t have a fatal error with your code.
Try the following approach:
ob_start();
if ( have_posts() ) {
wpbf_archive_header();
do_action( "wpbf_before_loop" );
while ( have_posts() ) {
the_post();
get_template_part( "inc/template-parts/article" );
}
do_action( "wpbf_after_loop" );
} else {
get_template_part( "inc/template-parts/article-none" );
}
$ob_content = ob_get_clean();
echo do_shortcode( '[su_spoiler title="Informations d\'Occitanie" open="yes" style="default" icon="plus" anchor="" class=""]' . $ob_content . '[/su_spoiler]' );
OB stands for Output Buffer.
Thread Starter
raidje
(@raidje)
thank you for your precious help….