Skip to content

Instantly share code, notes, and snippets.

@data-enhanced
Created June 9, 2015 18:37
Show Gist options
  • Select an option

  • Save data-enhanced/1a3b5dfc0ec750a066ee to your computer and use it in GitHub Desktop.

Select an option

Save data-enhanced/1a3b5dfc0ec750a066ee to your computer and use it in GitHub Desktop.
WP excerpt remove p tags
<?php
$myExcerpt = get_the_excerpt();
$tags = array("<p>", "</p>");
$myExcerpt = str_replace($tags, "", $myExcerpt);
echo $myExcerpt;
?>
<!-- https://wordpress.org/support/topic/remove-ltpgt-tag-from-excerpt -->
@Tusko
Copy link

Tusko commented Feb 11, 2020

The better way is wp_strip_all_tags(get_the_excerpt())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment