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
- Using ACF Relationship field to set post type to draft or published status
- How to hide a child category and show his parent category
- Display logged in user name and lastname on page
- Adding wp users ID into a link address from a DIVI modul
- How to Add a cutsom slug to my custom author role
- Execute function only for specific user roles
- How to send a php var to jQuery Ajax call with two different file
- Providin exception to WordPress wp_nav_menu Custom CSS Classes
- Unable to display multiple parameters from url by javascript through shortcodes
- Change wordpress’ database data using ajax – how to get current user id?
- Woocommerce My acount page
- Woocommerce – Exclude variation attribute on specific variation
- Dynamically populate parameter in Gravity Forms using PHP
- How do I add a function to parent theme
- Can’t log in to WordPress wp-admin after adding code to functions.php
- Allow two posts (from different categories) to have the same slug
- Are there any drawbacks on opening a session_start in functions.php and header.php?
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- How a HTML form can trigger a PHP function?
- Prepend to all image URLs with PHP, only for mobile devices
- Dropdown category field inside repeatable metabox
- How to change basename url for wp-admin?
- Create shortcode for metabox gallery
- Allow a user or role to view drafts and previews, but not other admin privileges?
- Retrieve alt text by referencing the img src
- How to exclude meta no index pages from wp_list_pages
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- Adding HTML Code to Replace Text in PHP
- Get nice name of category from slug (remove dashes of category)
- How to Send Pingbacks for all Posts in WordPress?
- Reliable way to add nonce to HTTP Header in WordPress?
- Products listing check if meta checkbox is checked
- Show all people who commented on all posts by an author
- Trying to update Woocommerce meta values
- how to replace h1 entry title with h2 in category pages only
- Display Visual Composer shortcode if a post belongs in specific categories
- Custom function that re-writes page title breaks when the Yoast plugin is activated
- How to unset a function from a action inside a class, that is called in another class
- Create a new account on site B with data from the purchase of site A
- Why is the current page loaded in the pop-up window and not the specified one?
- How to preload header logo image in WordPress? like what’s the code and where do I put it?
- Add Featured Image to Existing Post
- 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
- How to get latest post ID in functions.php?
- is_front_page is not working in my functions.php
- Is it possible to update the dataset using update_post_meta
- Billing detail page doesn’t work after I’ve changed the order of the Woocommerce navigation
- add another variable to php function
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Contain multiple page templates in one PHP custom template file in WordPress?
- if get_post_meta is empty echo a placeholder or shortcode
- How do I reopen the (Popup Maker) after entering the correct password for a password protected page?
- Display metabox galleries on specific page template in admin editor
- PHP function for horizontal Woocommerce thumbnails and badges
- copy fields value to another field
- display condition based on post term and status
- Only the first image uploads
- How to output the taxonomies that are assigned to each custom post?
- Limit Search to Product Pages only unless I’m on Blogpage or Blogposts
- WP query posts BUT show the most recent and one per author
- Block error message in foreach loop when looping through ACF field
- Include User ID in iFrame URL
- WP custom posts: filter results to custom taxonomy tag that corresponds to user meta field
- not outputting medium size image URL
- Gutenberg block don’t save rich text content
- Search by date in WordPress
- Run a sql (update) after 12 hours after the user login. Woocommerce users
- Wp_Schedule_Event every few minutes doesn’t work
- Get current user id in function php
- Proper way to remove html code on child theme
- remove_action from parent theme using child theme functions.php
- Trying to add Custom Post Type to this functions.php command
- Add Pre-Defined Value to Click Counter in WordPress
- Apply function.php filter only if url not has /amp/
- Hide a div if the fiels is empty
- File from parent theme imported to child theme doesn’t work – any ideas?
- Illegal string offset checkbox
- Ajax filter with loadmore button
- Cant get blog name with get_option
- Problem with displaying CSS Stylesheets – Am I adding them correctly in my wordpress child theme?
- Preventing direct access to a page in WordPress