I'm trying to exclude several urls from appending a nofollow rule using strpos but it only works with 1 url, I can't get it to exclude all the urls I need to include.
This is the code that I've tried:
add_filter( 'custom_bbpress_nofollow', 'my_custom_bbpress_nofollow', 15, 2 );
function my_custom_bbpress_nofollow( $nofollow, $href ) {
if ( strpos( $href, 'https://www.examplelink1.com' ) === false && strpos( $href, 'https://www.examplelink2.com' ) === false && strpos( $href, 'https://www.examplelink3.com' ) === false && strpos( $href, 'https://examplelink4.to' ) === false) {
$nofollow = '';
}
return $nofollow;
}
I've tried it with == false
and !== false
as well and those don't seem to work.
This one DOES work, but it only excludes a single domain, I need to be able to exclude 5 in all.
add_filter( 'custom_bbpress_nofollow', 'my_custom_bbpress_nofollow', 15, 2 );
function my_custom_bbpress_nofollow( $nofollow, $href ) {
if ( strpos( $href, 'http://your-domain.here' ) !== false ) {
$nofollow = 'rel="dofollow"';
}
return $nofollow;
}
What is the correct strpos syntax to include multiple urls,
https://www.examplelink1.com AND/OR
https://www.examplelink2.com AND/OR
https://www.examplelink3.com AND/OR
https://www.examplelink4.com