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
- Usage of theme name in functions
- Run wp_kses_decode_entities on atom feed?
- Filtering out the #more anchor link that gets produced by
- Can’t filter wp_get_attachment_link
- Functions.php Problem
- Redirect to another page using contact form 7? [closed]
- append to existing parent theme function
- ACF not showing
- 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 can I add a filter for specific categories on functions.php?
- How to add custom JavaScript in functions?
- Setting a default text for excerpts of a particular category
- How to edit the Tags within the image file URLs?
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- Can’t properly set the_title add_filter to show short_URL
- Add_filter when value is no variable?
- Control the srcset much more (not all sizes in it each time)
- Check if the image size is available and if not use ‘full’ image size
- Way to store featured image width and height in two separate variables?
- Insert template-part inside the content
- How to add_filter html template to middle of content
- Remove Custuomize Sections
- (Woocommerce) Order by price when entering specific category
- Filter an WordPress Function in (general-template.php)
- Can we create our own theme’s function.php?
- Define PHP variable from a seperate API if statement
- Remove links from the_content when using filters wp_trim_excerpt
- Excerpt for pages not showing
- get_pages() Returns Only One Item
- Redefine function arguments before rendering
- 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?
- Filter nav menu items HTML tags and wrap inner text with span
- Possible to hook into Media Library preview File column and use a custom image?
- How can I add a class to a nav li depending on URL?
- Does size of a theme’s functions.php file matter?
- Functions php shortcode for displaying main menu with no child items
- get_next_posts_link() returns no result despite available posts
- Nav menus all outputting the same links
- Modify gform_other_choice_value for specific form and specific field in Gravity Forms
- does wp function the_content(); accept another tag inside
- PHP 7.1 | Warning: A non-numeric value encountered in
- Combine embed_oembed_html and oembed_result
- login_headertitle is deprecated since version 5.2.0
- Undefined variable error in new function
- Set “woocommerce_is_purchasable” to false for specific “$product->is_stock_status”
- How to remove a specific word at the beginning of the content and add it to the end of the content
- How to display the_archive_title() and the_archive_description() – “weird” interaction
- Filter to wp_list_authors
- How to add custom li item to wordpress menu
- Native gallery custom html output
- How to insert class in each list of categories?
- I can’t add CSS with functions.php
- Getting the teaser text without overriding global variables
- Combine two active_callbacks into one on theme customizer
- first paragraph of the_content as meta description
- WP Customizer API loaded into functions.php
- How to edit/replace Parent functions.php function in Child Theme to add “Walker” class
- call_user_func_array() expects parameter 1 to be a valid callback, function
- why can’t i add front.css to my frontpage.php
- Functions Filter Question [closed]
- Changing where my author box is printed
- Is it possible to use add_filter in an included file in the child theme’s functions.php?
- “options.php” not found
- Add Adsense code between job listings – wp job manager plugin
- How to store a number (coming from cookie) into query vars for later usage in other filters?
- How to add aria role and schema markup to custom walker container
- Problem with images URL after filter applying
- remove_action not working, even after changing priority [duplicate]
- Is this an acceptable practice for WordPress theme development?
- remove/hide wp-editor
- What is the correct way to include my new functions and scripts in WordPress?
- wp_nav_menu work in functions.php but not in the theme
- Rewrite Question Mark in Post Template with URL Parameter for clean URLs
- Replace header image on all other pages but home – URL issue
- Add a class to post if it has been recently updated
- contact form in template with jquery,validate and ajax
- search form leads to 404
- 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?