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
- How to pass hook variable to function?
- Remove submenu item from list
- pagination broken – clicking next displays “page not found”
- Get the alt text of the image in a array
- How to prevent a function from running based on host (ie web vs local)?
- If is_single in functions.php
- call a string/function from database
- How to call custom function outside from the admin page?
- making php value numeric
- Add a select-option to the default widgets
- How to break up php code to avoid echo
- Defining multiple categories for showing latest posts
- the_post_thumbnail issues
- Is there a way to create a “copy post” link?
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Display additional page templates and a sidebar on plugin activation
- Dynamic Menu drops pages?
- Adding a ‘style=’ bit to image_send_to_editor output
- Post Views Code Hacks
- Closing WP_LINK_PAGES DIV ID w/After Argmuent
- Aspx/Rss feed – failed to open stream: Redirection limit reached
- Adding an Unlinked Space in a Custom Function
- exclude custom post type from running a function
- Taxonomy term description with style, only if the description exists?
- Exclude function from running on a certain page
- Convert all uploaded PNG files to PNG-8 format
- AJAX function not working [closed]
- Migrating site, only header shows
- Customize field names in backend profile edit page through function.php [duplicate]
- Search.php gets metadata from first post
- Make table disappear when fields are left blank?
- Menu not styling. New menus functionality giving me a headache
- Get date function not working
- How to create Loop code for Menu using WordPress?
- Add class to every other posts using get_posts
- Pagination Not Working (pages duplicating content)
- Use of antispambot with $curauth->email
- the_post(); prints out style text into my HTML?
- Auto create Nextgen Gallery on post creation [closed]
- Uses for function: wp_update_user
- How do I call an external php non WordPress class into functions.php?
- Insert content into head tag with function
- Function to call either single post or category
- Custom functions for string data calculations
- How are these PHP functions applied to a specific page in WordPress?
- WP insert post Redirect after function has executed
- SQL error with custom query
- The additional fee for the COD payment method not visible in the front-end
- Hide media for non logged in users
- Programmatically revert to backup .htaccess a possibility?
- PHP identify duplicate words in a text string against a list of words
- How to access all meta data for RSS feed?
- Why Is Number of views on wordpress single post wrong?
- Search AJAX Filters – Multiple Query Loops Into One Loop (Optimization)
- Restrict post to current user in postmeta
- Wp Query : Order by distance lat,lon