Filter texts without wordpress formatting

Asked

Viewed 23 times

0

How could I filter only the text, that is what are outside of the tags, the ones that are in the html tags I want to remain, I just don’t want the ones that are in these [/et_pb_text] tag types or I don’t want to, how to filter only the text? Obs: I’m doing in php, example:

[/et_pb_text][et_pb_code admin_label=""Code"" disabled=""off""][ess_grid alias="Homepage"][/et_pb_code][/et_pb_column][et_pb_column type=""1_4""][et_pb_text admin_label=""performers-title"" background_layout=""light"" text_orientation=""left"" use_border_color=""off"" border_style=""solid"" custom_margin=""||5px|"" disabled=""off""]

<h2>Based in London and working on events both across the UK and internationally</h2>
Contraband International is a high-end artist, event and entertainment agency. We supply the very best entertainers and performers for all types of <strong>corporate entertainment</strong> events and parties, private celebrations, PR campaigns, marketing stunts and international events. It’s our expertise, creativity and friendly approach which makes us the most sought-after talent and entertainment agency in the UK.
<h4>Performers</h4>

[/et_pb_text][et_pb_code admin_label=""Code"" disabled=""off""][ess_grid alias=&quot;Performers&quot;][/et_pb_code][/et_pb_column][et_pb_column type=""1_4""][et_pb_text admin_label=""Reality TV-title"" background_layout=""light"" text_orientation=""left"" use_border_color=""off"" border_style=""solid"" custom_margin=""||5px|"" disabled=""off"" border_color=""#ffffff""]

I want to filter only what is readable as the contents of H2, H4, and plain text

1 answer

1


Use wp_kses to filter your content only with tags allowed:

// remove todas as tags exceto as h2
echo wp_kses( $post->post_content, array( 'h2' => array() );

The link has the correct format of the array of the second parameter, which indicates the allowed tags and attributes.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.