You actually already were pretty close:
function autoblank($text) {
$return = str_replace('href="https://wordpress.stackexchange.com/questions/138730/,"target="_blank" href=", $text);
$return = str_replace(
"target="_blank" href="' . get_site_url(),
'href="' . get_site_url(),
$return
);
$return = str_replace('target="_blank" href="#"https://wordpress.stackexchange.com/questions/138730/,"href="#', $return);
return $return;
}
add_filter('the_content"https://wordpress.stackexchange.com/questions/138730/,"autoblank');
add_filter('comment_text"https://wordpress.stackexchange.com/questions/138730/,"autoblank');
Related Posts:
- Dynamic URL to reference custom PHP files
- How do I get the author’s page url from their ID?
- Concatenate site_url and string doesn’t work
- Remove query string specific key value
- Scrape external webpage for first image and add it to new post
- Need help enqueueing webfonts
- Get the URL of the page from which an ajax request has been launched within ajax callback
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Creating customized php files in theme folder
- How to add PHP pagination to wordpress
- Workaround for og:image unsupported webp image type, Yoast SEO?
- How to define a rule in functions.php that ONLY disables the default wp functionality that undesirably changes ‘&’ to ‘#038;’?
- Need to Echo A Url path to show on a wordpress page
- site_url() returns with additional backslashes
- Whats wrong with my code? Need To add String to shortcode? [closed]
- How to extract URLs from wordpress taxonomies
- Is it safe to use $_SERVER[‘REQUEST_URI’]?
- The correct method to pass query vars in AJAX using ajaxurl
- WordPress Infinite Scroll without using any plugin
- How to remove a metabox from menu editor page?
- How to overwrite youtube embed?
- New Plugin Review
- Problems with function on function.php
- How to add SVG icon above product tab title
- is_page “range” for if statement?
- WordPress child theme fails to override parent navigation menu in /inc/structure/header.php
- jQuery not defined
- Converting HTML Template to WordPress Theme
- Add data attribute to each li in menu
- Prev/Next child navigation for current page modifications?
- Adding rel tag to all external links
- How can I apply_filters from inside a function?
- Pass Category Name, Description and Photo into variables to pass to jQuery
- Populate editor with some content of a page with a page template
- I want to load in a new class but only if the current page is single-movies.php
- Skt full width basic slideshow problem
- Create custom permalinks to show Custom Post Type’s relationship?
- Need to put a script above tag in header.php – WP 5.7.1
- How to make container class in PHP
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- How to show/hide php table rows based on the content of custom fields
- How to call multiple functions from multiple files into a WordPress page template [closed]
- Prev/Next Links Broken on Static Front Page Pagination
- Isotope Drop Down Categories Filter Function
- What is the best way to define constant options for a theme?
- Is there a built-in function to generate multiple paragraph tags based on a string with new line separators?
- How to add no follow to specific links?
- Function for simple math doesn’t work what am I doing wrong? [closed]
- How to hide the author box of a specific user?
- Add date before entry title in Twenty Twelve
- How do i wrap woocomerce attribute in list?
- Removing files programmatically
- Class property seems to lose scope, attached to save_post action?
- Nav-Menu not showing up
- Show different website layout if no sidebar added
- WordPress theme showing blank page
- get_template_part function and add images
- Need advice on theme customizer and child themes
- How to make sure relative URL works when site is not on root domain?
- How to pass hook variable to function?
- exclude custom post type from running a function
- Migrating site, only header shows
- The additional fee for the COD payment method not visible in the front-end
- WordPress is removing query variables like page, p from the URL of a custom static page
- 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?
- Change Language Title Pagination on Subdomain non Multisite
- remove specificly the last tag in all posts
- How to use Page link field with is_page()
- How to hide a child category and show his parent category
- How to add and subtract user meta values after post meta update
- how can i redirect dynamic URL in worpress base on ID in htaccess or wp-config or function.php
- Multiple AJAX handler functions conflict in functions.php
- add another variable to php function
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Gutenberg block don’t save rich text content
- Change lost password url to a mailto URL in WordPress
- How to change this ajax function to submit to the default wordpress content area instead of the custom field ‘seller notes’?
- Remove span tags from WooCommerce Downloads page
- Send POST request to Flask app from functions.php file
- 500 Error, Get custom field and returning it
- How to add typehints to function in functions.php when argument is an object?
- Remove generated category and tag class names from woocommerce product & blog listings markup
- is_user_logged_in() not working in homepage
- Custom Post type Ajax search results
- I want url from a file in media using title file
- str_replace not preserving whitespace
- Calling PHP function doesn’t work in index.php
- How to set up an auto delete post?
- Display a post based on its metabox selection
- Search box background on a different page template
- How to modify this function to exclude also the post belonging to a specific category?
- Remove /category/ from category (archive) page URLs (without using a plugin)
- Dynamic Email Handler with ‘header (“Location: …’
- WooCommerce: write featured image dimensions to custom fields in product’
- How can I change the URL via add_rewrite_rule()
- Generate and upload screenshot as featured image for user-submitted post
- How to change all the urls of the WordPress site?
- transition_post_status hook, works – but not if the post is new