Title: CSS missing when using the_content()
Last modified: February 23, 2022

---

# CSS missing when using the_content()

 *  Resolved [Amibe Websites](https://wordpress.org/support/users/amibe/)
 * (@amibe)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/css-missing-when-using-the_content/)
 * Hi, thank you for this plugin.
 * I’m pulling in content using WP_Query and a “while ( have_posts() ) : the_post()”
   loop, using the_content() to output the post.
 * The CSS isn’t included – what can I add to this to make sure the CSS is also 
   outputted with each post?

Viewing 1 replies (of 1 total)

 *  Plugin Author [Hardeep Asrani](https://wordpress.org/support/users/hardeepasrani/)
 * (@hardeepasrani)
 * [4 years, 2 months ago](https://wordpress.org/support/topic/css-missing-when-using-the_content/#post-15409859)
 * Hey [@amibe](https://wordpress.org/support/users/amibe/),
 * Inside your query, you can do something like this:
 *     ```
       $css = new \ThemeIsle\GutenbergBlocks\Blocks_CSS();
   
       $blocks = $css->parse_blocks( get_the_content() );
   
       if ( ! is_array( $blocks ) || empty( $blocks ) ) {
       	return;
       }
   
       $css = $css->cycle_through_blocks( $blocks, get_the_ID() );
   
       if ( empty( $css ) ) {
       	return;
       }
   
       $style  = "\n" . '<style type="text/css" media="all">' . "\n";
       $style .= $css;
       $style .= "\n" . '</style>' . "\n";
   
       echo $style;
       ```
   
 * Let me know if that works!
    -  This reply was modified 4 years, 2 months ago by [Hardeep Asrani](https://wordpress.org/support/users/hardeepasrani/).

Viewing 1 replies (of 1 total)

The topic ‘CSS missing when using the_content()’ is closed to new replies.

 * ![](https://ps.w.org/blocks-css/assets/icon-256x256.jpg?rev=2030330)
 * [Blocks CSS: CSS Editor for Gutenberg Blocks](https://wordpress.org/plugins/blocks-css/)
 * [Support Threads](https://wordpress.org/support/plugin/blocks-css/)
 * [Active Topics](https://wordpress.org/support/plugin/blocks-css/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/blocks-css/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/blocks-css/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [Hardeep Asrani](https://wordpress.org/support/users/hardeepasrani/)
 * Last activity: [4 years, 2 months ago](https://wordpress.org/support/topic/css-missing-when-using-the_content/#post-15409859)
 * Status: resolved