Good day to all! There is such a question. The site has links to pages for example:

<a href="/contact/">Contact</a> <a href="/info/">Info</a> 

It is necessary to make it so that being for example on the Contact page, the link to the Contact page becomes inactive. For this, I wrote a function, but it does not work. how to fix?

 function no_link( $p ) { return preg_replace( '%((loop-link|loop-link)[^<]+)[^>]+>([^<]+)</a>%', '$1<a>$3</a>', $p, 1 ); } add_filter('no_link'); 

    1 answer 1

    Example:

     $links = [ '/contact/' => 'main', '/info/' => 'page 1', '/info2/' => 'page 2' ]; foreach ($links as $link => $text) { if (strpos("@". $_SERVER['REQUEST_URI'], $link )) { echo "<div><font>$text</font></div>"; } else { echo "<div><A HREF='links.php?p=" . $link . "'>$text</A></div>"; } }