Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
First, you need to create a page with the 'out' slug or a custom rewrite rule with the same slug.
Second, we need to teach WP to recognize the 'url' GET variable.
Thirdly, on this page or request (in the case of a rewrite rule), you need to add a function that will check this 'url' GET variable, make sure that it is safe and correct, and perform a redirect.
This is a purely functional part, the handler of the redirect itself by such a scheme.
The second part will be generating the correct links, given the attribute. And here it is already necessary to clarify many points - where the links will be placed, as well as so on.
I have described the logic of work to you here, a complete answer with examples of code pieces is beyond the scope of the Toaster, this is a task for freelancing. If you want to try to solve it yourself - re-read the logic and start working. As more narrow and specific questions appear, ask.
As I understand it, you need to add the nofollow attribute to external links. I myself use the following code:
Add to functions.php
Before adding, replace md7.info with the address of YOUR site
// nofollow noopener noreferrer
function add_nofollow_content($content)
{
$content = preg_replace_callback(
'/<a[^>]*href=["|\']([^"|\']*)["|\'][^>]*>([^<]*)<\/a>/i',
function($m) {
if (strpos($m[1], "md7.info") === false)
return '<a href="'.$m[1].'" rel="nofollow noopener noreferrer" target="_blank">'.$m[2].'</a>';
else
return '<a href="'.$m[1].'" target="_blank">'.$m[2].'</a>';
},
$content);
return $content;
}
add_filter('the_content', 'add_nofollow_content');
// nofollow noopener noreferrer for ACF
function add_nofollow_acf($field) {
$field = preg_replace_callback(
'/<a[^>]*href=["|\']([^"|\']*)["|\'][^>]*>([^<]*)<\/a>/i',
function($m) {
if (strpos($m[1], "md7.info") === false)
return '<a href="'.$m[1].'" rel="nofollow noopener noreferrer" target="_blank">'.$m[2].'</a>';
else
return '<a href="'.$m[1].'" target="_blank">'.$m[2].'</a>';
},
$field);
return $field;
}
add_filter('acf/load_value', 'add_nofollow_acf');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question