Manipulating HTML with regular expressions is not a good idea. I suggest you use DOMDocument:
// input
$html = apply_filters('the_content', get_the_content());
$dom = new \DomDocument();
$dom->loadHtml($html);
$blockquotes = $dom->getElementsByTagName('blockquote');
foreach($blockquotes as $blockquote){
foreach($blockquote->childNodes as $e){
if($e->nodeName === 'p'){
// create a text node with the contents of the <p>
$blockquote->insertBefore($dom->createTextNode($e->textContent), $e);
// remove <p>
$blockquote->removeChild($e);
}
}
}
// remove doctype
$dom->removeChild($dom->firstChild);
$dom->replaceChild($dom->firstChild->firstChild->firstChild, $dom->firstChild);
print $dom->saveHtml();
Related Posts:
- Removing “wpautop” (auto tags) only on certain pages?
- What is This esc_html_e() i wordpress php?
- Build a content and excerpt grid loop with paging and options for # of posts
- Displaying post per day
- How to add active class to custom menu using while loop and wp_list_pages
- Changing the HTML Of the content
- delete an array element when its date expires
- How can I loop into two different DIVS without repeating the DIVs
- Output 2 items within the Loop
- How to speed up a wordpress function with multiple loops?
- Custom excerpt function re-factoring
- Removing unneccessary p-tags (Not every p)
- Get first URL from post content
- Showing content from one page on another
- Show css depending on activity type in BuddyPress activity-loop [closed]
- get author_name from queried post
- Blog posts repeat
- how to refresh div on template part?
- Can’t find infinite loop cause
- Checking array against author id in loop
- Custom Pagination is Broken
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- use loop to return blog details
- How to get current post category details inside “loop”?
- Calling function in loop causes repeat data
- Problem in replacing the_content with the_excerpt()
- How to Add a cutsom slug to my custom author role
- Give ID to divs inside the loop
- Products listing check if meta checkbox is checked
- How to output the taxonomies that are assigned to each custom post?
- update_user_meta as multiple value but with same meta key
- cURL needing to loop through all “next_page”
- How to bind each “the_content” elements to a custom variables
- WordPress Ajax filter: Create two loops for different output styles?
- How can I get my pagination loop to display the correct number of total pages?
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- How fix error in the WordPress loop?
- My query keeps looping infinitely ! how to stop it?
- Retrieving specific images from Media Library
- Modify category archive page loop on functions.php
- Pagenav Not appearing on custom Template
- Excerpt all post content Content Same Size without word cutting off
- Options.php loop won’t show!
- Loop on a wordpress Page instead of content coming from the WP text editor
- Cleaning up WordPress to improve performance?
- How can I modify the permalink via a filter?
- wp_set_object_terms and arrays
- The best way to customize “nav-menu-template.php” to add if the ‘link_before’ is “checkbox”
- Woocommerce, recognize the loop of related products
- Easiest way to show total number of subpages
- Output a WooCommerce product custom field in WooCommerce using get_post_meta()
- WordPress blockquote removes “ tag
- Can’t load WP function into external function
- Image as Sales Badge
- WSoD being caused by this piece of code
- How to Arrange PHP Files to Allow for Multiple Types of Pages?
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Scrape external webpage for first image and add it to new post
- Fatal Errors on pluggable.php
- Log in / Log Out Custom Button
- How to debug this search & replace strings snippet?
- PHP Warning: strip_tags() expects parameter 1 to be string?
- Limit Taxonomy Output in Conditional Statement
- wp_redirect only works on main site and not on other sites
- How to modify the default feed via a function
- require_once() if a product in woocommerce contains a tag [closed]
- Loop over Array and get the distinct ids
- How do I change this function from two returns to one string to show sku and dimensions in WooCommerce cart?
- Only show first image in foreach loop
- How to remove the space before the ellipsis in excerpt?
- Convert all uploaded PNG files to PNG-8 format
- Uses for function: wp_update_user
- Wp Query : Order by distance lat,lon
- How to Redirect Buddypress Directories To Login Page For Non Logged in Users
- Woocommerce order status payment
- Display logged in user name and lastname on page
- Looping through dummy posts and showing them in the main index.php
- Exclude category from function – PHP
- Replace an array (with identical values) with another array in the_content
- Display current user metadata on WordPress page
- Need help with AJAX login to call php in functions.php to handle redirects based on user cap (role)
- How to count posts posts if they are in a separate content page?
- Populate Posts based on category selected using AJAX that means without page refresh
- Why transition_post_type hook is called twice for the same post?
- Can’t get_users info by using json_encode
- What is wrong in this code?
- Custom Taxonomy Link Text Echo Name Not Slug
- Page returning ID from array, how to return the correct values for post in acf wordpress
- Permission error on plugin save
- Removing all my hardcoded URLs with get_site_url()
- WordPress 2014 Theme – Featured Content with multiple tags?
- Display default WordPress login/registration form into a modal window
- Highlight main menu when on specific posts or pages
- Pull GET parameter from URL in functions.php
- Adding Gravity Form With if(is_page) Is Not Working
- Implement “No related posts for this entry” into the loop?
- Woocommerce – Shipping tax class based on cart items not using the highest tax available
- How to display the date under the post title?
- Creating mixture of shortcodes to use in the visual/text editor