title: Counting the total number of paragraphs on a wordpress blog post
body: <p>I've written a small snippet to count the total number of paragraph on any WordPress blog post so that it can return that number and based on that number I can do other stuff. But it seems not be working properly. Any anyone take a look and tell me why?</p>
  
  <p><strong>What I Want my code to return?</strong></p>
  
  <p>I want my code to return the total number of paragraphs on each blog post.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>//Check paragraph count on a blog post
  function __check_paragraph_count_blog() {
      if ( is_singular( 'post' ) ) {
          $content = apply_filters('the_content', $post-&gt;post_content);
          $contents = explode("&lt;/p&gt;", $content);
          $p_count = 1;
          foreach($contents as $content) {
              $p_count++;
          }
  
          return $p_count;
      }
  }
  </code></pre>
  
  <p>Any help will be highly appreciated.</p>