Adding custom shortcode to page leads to page without styling
Shortcodes need to return their values, but the_content() echoes the post content. So you have two options. First is to capture all output and then return it at the end: ob_start(); // Start capturing output; while( $loop->have_posts() ) { $loop->the_post(); the_content(); }; wp_reset_postdata(); return ob_get_clean(); // Return captured output; That will be the cleanest way … Read more