WordPress automatically adds target="blank" attribute to the outer chain
Method 1:
Add the following code directly to the functions.php
Medium
- function autoblank( $text ) {
- $return = str_replace ('<a', '<a?target= "_blank" ', $text );
- return $return ;
- }
- add_filter('the_content', 'autoblank');
Method 2:
It is implemented by JQ code and can be directly added to the main JS. At least I tried it this way. If you have problems after trying, you can leave a message for feedback.
- var ? root?=?location.protocol?+?'//'?+?location.host;
- $('a').not(':contains(root)').click( function (){
- this .target?=? "_blank" ;
- });
In fact, another way is to choose to open in a new window when adding links. This function can also be achieved. If there are few articles, you can still use code.