Skip to content

Instantly share code, notes, and snippets.

@ramsesdelr
Created June 28, 2024 23:49
Show Gist options
  • Select an option

  • Save ramsesdelr/01495bb407710066794c2e91826e5f6e to your computer and use it in GitHub Desktop.

Select an option

Save ramsesdelr/01495bb407710066794c2e91826e5f6e to your computer and use it in GitHub Desktop.
<?php
// search all <span> tags from a post.
$processor = new \\WP_HTML_Tag_Processor( $content );
$processor->next_tag( [ 'tag_name' => 'span' ] ); // search by tag
$processor->next_tag( [ 'class_name' => 'fullwidth' ] ); // search by class name
$processor->next_tag( [ 'class_name' => 'fullwidth', 'tag_name' => 'img' ] ); // search by class name and by tag name at the same time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment