Answers.Body: <p>Actually, the <code>striptags</code> filter (which is just a wrapper for the PHP <a href="http://php.net/manual/en/function.strip-tags.php" rel="noreferrer">strip_tags</a> function) removes all HTML tags <em>except the ones you pass in</em>.</p>
  
  <p>In other words, if you want to remove <code>&lt;p&gt;</code> tags, just use the <code>striptags</code> filter without any parameters:</p>
  
  <pre><code>{# Will remove all HTML tags #}
  &lt;p class="slider--text"&gt;{{ product.intro|striptags|raw }}&lt;/p&gt;
  </code></pre>
  
  <p>If there are other tags you want to retain, you'll need to pass those in:</p>
  
  <pre><code>{# Will remove all tags except &lt;br&gt; and &lt;img&gt; #}
  &lt;p class="slider--text"&gt;{{ product.intro|striptags('&lt;br&gt;&lt;img&gt;')|raw }}&lt;/p&gt;
  </code></pre>
  
  <p>For a different take on stripping tags, you can use <a href="https://github.com/mmikkel/RetconHTML-Craft" rel="noreferrer">the Retcon plugin</a> (which I wrote). With Retcon, you can remove all <code>&lt;p&gt;</code> tags (and only <code>&lt;p&gt;</code> tags; retaining their contents as well as all other tags) easily by using the <a href="https://github.com/mmikkel/RetconHTML-Craft/wiki/Change" rel="noreferrer"><code>retconChange</code></a> filter:</p>
  
  <pre><code>&lt;p class="slider--text"&gt;{{ product.intro|retconChange('&lt;p&gt;', false) }}&lt;/p&gt;
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-01-21T14:04:07.080Z
Answers.LastActivityDate: 2017-01-21T15:28:28.473Z
Answers.LastEditDate: 2017-01-21T15:28:28.473Z
Answers.UserDisplayName: Mats Mikkel Rummelhoff
Body: <p>I've seen how you can remove html tags with twig in other posts here so I am using:</p>
  
  <pre><code>&lt;p class="slider--text"&gt;{{ product.intro|striptags('&lt;p&gt;')|raw }}&lt;/p&gt;
  </code></pre>
  
  <p>To remove the <code>&lt;p&gt;</code> tag that redactor adds automatically. However for some reason it is not removing it. Anyone have any ideas. Have I missed something glaringly obvious?</p>
  
  <p>Cheers</p>
  
Tags: <templating>
Title: striptags not removing <p> tag?
ThreadText: # striptags not removing <p> tag?
  
  (Asked by: username_0 on 2017-01-21)
  
  I've seen how you can remove html tags with twig in other posts here so I am using:
  
  ```
  <p class="slider--text">{{ product.intro|striptags('<p>')|raw }}</p>
  
  ```
  
  To remove the `<p>` tag that redactor adds automatically. However for some reason it is not removing it. Anyone have any ideas. Have I missed something glaringly obvious?
  
  Cheers
  
  **Tags:** templating
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2017-01-21. Score: 13
  
  Actually, the `striptags` filter (which is just a wrapper for the PHP [strip\_tags](http://php.net/manual/en/function.strip-tags.php) function) removes all HTML tags *except the ones you pass in*.
  
  In other words, if you want to remove `<p>` tags, just use the `striptags` filter without any parameters:
  
  ```
  {# Will remove all HTML tags #}
  <p class="slider--text">{{ product.intro|striptags|raw }}</p>
  
  ```
  
  If there are other tags you want to retain, you'll need to pass those in:
  
  ```
  {# Will remove all tags except <br> and <img> #}
  <p class="slider--text">{{ product.intro|striptags('<br><img>')|raw }}</p>
  
  ```
  
  For a different take on stripping tags, you can use [the Retcon plugin](https://github.com/mmikkel/RetconHTML-Craft) (which I wrote). With Retcon, you can remove all `<p>` tags (and only `<p>` tags; retaining their contents as well as all other tags) easily by using the [`retconChange`](https://github.com/mmikkel/RetconHTML-Craft/wiki/Change) filter:
  
  ```
  <p class="slider--text">{{ product.intro|retconChange('<p>', false) }}</p>
  
  ```
  
  
  ---
  
  