How can I check if a custom fiel called description
has a heading inside the text?
Take this as an example:
<h2>whatever in the heading</h2>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo
If description
is your field name then you can try with this code.
<?php
$title = get_field( 'description' ); // <h2>whatever in the heading</h2>
if ( strpos( $title, '<h2>' ) !== false) {
echo 'H2 is exist.';
} else {
//Your Statement
}
?>
', $description ) );`
– MonkeyZeus Nov 21 '19 at 20:42