You’re using the correct approach, minor replacement needed! ..
Simply replace
$content = preg_replace('/<a href=\"(.*?)\">(.*?)<\/a>/', "", $content);
with
$content = preg_replace(array('"<a href(.*?)>"', '"</a>"'), array('',''), $content);
Related Posts:
- Issues with title-tag and document_title_parts
- Show excerpt for only first post in query
- How to filter out shortcode when displaying the_excerpt() in the loop?
- str_replace function in theme
- Adding HTML to the end of every post with the Block Editor
- Add caption functionality to custom WordPress theme
- Add Element as a Filter to the_content
- The_content and Preg_replace in loaded Iframe [closed]
- Insert Content Before div#main from the functions.php File
- $content is empty while using DOMDocument
- Shortcode to eliminate and replace with
- Regex works in regexr, but not if I filter content [closed]
- Allow tags and attributes in post and pages content
- Change admin bar to default:off
- Insert Custom HTML After Shortcode
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- Insert Ad Code in the Middle of a Post
- How to reduce original image quality on upload?
- Add body class of category parent
- Convert hyphen to underscore in permalinks
- Programmatically Add Font-Awesome Icons to Category Widget
- Change parent theme file function in child themes functions.php
- Remove bulk actions based on user role or capabilities
- How to override filter in child theme?
- How to change a certain text or term of WordPress into a custom into the whole site?
- Adding body class when post contains a specific shortcode
- Displaying Widgets
- Replacing with(out) regex link to attachment by links to files
- Manipulate Output of wp_list_something: select menu instead of li’s
- Overwrite Parent Theme add_image_size in Child Theme
- Post Pagination Showing Same Posts Every Page
- How to add css class to image attached in all the posts?
- Is there a way to add a class to non current menu item?
- Can’t check if a post has thumbnail adding filter to get_post_metadata()
- Inserting a functions output after the content
- Modify Image Source With The_Content Filter?
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Passing values from a widget to a function within a plugin
- Removing permalink from post thumb in twentyeleven
- Publish/Update post is changing image links from file url to post url
- How do I add custom bulk actions to multiple custom post types?
- Best practices regarding the creation of custom widgets?
- Is possible add icon in title posts only in specific tag?
- admin-ajax.php + load-scripts.php hanging for minutes
- Replace a menu with widget or a custom template file programmatically
- Unique sequential reservation code
- Run wp_kses_decode_entities on atom feed?
- Can’t filter wp_get_attachment_link
- How to customize the_archive_title()? Cannot figure out how to change the value it produces [duplicate]
- Override the WordPress core function wp_referer_field
- Modify post filter to set custom number of posts per page and exclude child posts
- Make wp_link_pages() suitable for Twitter Bootstrap markup
- Replace single_template filter with what for default posts?
- How to edit the Tags within the image file URLs?
- Control the srcset much more (not all sizes in it each time)
- How to add_filter html template to middle of content
- Some questions about how proper add 2 CSS file in a WordPress theme?
- How to edit classes in body tag?
- How do I pull excerpts from pages?
- Combine embed_oembed_html and oembed_result
- Native gallery custom html output
- why can’t i add front.css to my frontpage.php
- Functions Filter Question [closed]
- Changing where my author box is printed
- contact form in template with jquery,validate and ajax
- Why a SlideShow (made using JQuery FlexSlider) can’t work if I load it form functions.php but work if I load it from my footer.php file? [closed]
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- How to set default values for edit_post_link() in my theme?
- Any adverse effects of adding apply_filters to a function?
- Woocommerce Variable Product Dropdown for Custom Shop Template
- Advanced method to control cache of enqueued style/script
- Customizing the wp_video_shortcode output with add_filter
- Removing comment lines from all enqueued js files using a filter function
- How Do I Unhook This Parent Theme Function?
- Test CDN link from function.php or wp_enqueue_script/style?
- Allow user only create specific tags
- How to bind each “the_content” elements to a custom variables
- Why does echo on functions.php not yield result in source code?
- Child theme remove parent filter in functions
- How to wrap pattern-matches from the_content in [wiki]-shortcode tags
- add product thumbnail to checkout page only and include variation name
- Hide disclaimer from summary excerpts
- Class::$template_dir_path=get_template_directory();
- Only seems to be displaying one child when there are supposed to be multiple
- previous_post_link inside of a function?
- Search and Replace Script Loader in Head Only Works in Footer
- Problem in outputting shortcode
- wp_nav_walker that interacts with widgets to setup mega menu
- How to Add A Rel Filter to All Links?
- Add class to all parent elements inside the_content
- Override parent theme function that is not hooked or in the functions.php file
- Suppress the_content filter in a nested loop
- child_of not working while searching
- post->post_content filter
- How to Insert A List of Posts in A Category Written by the Author into the Author Archive
- Filter to strip unnecessary attributes
- preg_replace specific Text to small latter strtolower [closed]
- How I can show short content with short tag
- Warning: call_user_func_array() expects parameter 1 to be a valid callback
- Setcookie not setting cookies anywhere except admin