Drupal Paragraphs module - remove extra markup

897 Views Asked by At

I would like to remove the extra markup that is around the generated paragraph items.

<h1>
  <div class="field field-name-field-title field-type-text field-label-hidden">
    <div class="field-items">
      <div class="field-item even">Title</div>
    </div>
  </div>
</h1>

I would like it to display like this:

<h1>Title</h1>

I’ve not had any luck trying some of the suggestions in the Paragraphs issues https://www.drupal.org/node/2251909 such as editing the following files:

paragraphs-item.tpl.php
paragraphs-items.tpl.php
paragraphs.theme.inc

Does anyone have any experience with this module and be able to offer some assistance?

1

There are 1 best solutions below

1
PraveenKumar On

You can use strip_tags() to remove the html tags.

<h1><?php print strip_tags(render($content['YOUR_FIELD'])); ?></h1>

or

<?php print strip_tags(render($content['YOUR_FIELD']), "<h1>"); ?>

Hope this helps you.