Hello I try to keep only specific tag from an html string.
For example:
$allowed_tag=array('a');
$content = '<a href="#">link</a> <b>strong text</b>';
$content = prefix_remove_specific_tag($content, $allowed_tag);
echo $content
Will return
<a href="#">link</a> strong text
I'm sure a wp core function existe for that, but i can't find it :(
Hello I try to keep only specific tag from an html string.
For example:
$allowed_tag=array('a');
$content = '<a href="#">link</a> <b>strong text</b>';
$content = prefix_remove_specific_tag($content, $allowed_tag);
echo $content
Will return
<a href="#">link</a> strong text
I'm sure a wp core function existe for that, but i can't find it :(
Share Improve this question edited Oct 16, 2019 at 8:05 ZecKa asked Oct 16, 2019 at 6:59 ZecKaZecKa 7781 gold badge6 silver badges12 bronze badges1 Answer
Reset to default 0I had to ask to finally find the solution, lol.
The wp_kses do exactly that:
$allowed_tags = array(
'a' => array(
'href' => array(),
),
);
$content = '<a href="#">link</a> <b>strong text</b>';
$content = wp_kses($content, $allowed_tags);
I found the solution in another topic