Are you ever annoyed by the way WordPress pingbacks when you add an internal link to a post or page? The following code snippet will stop self-pingbacks in their tracks. Add it to your functions.php and give it a try.
1 2 3 4 5 6 7 8 9 10 11 12 13 | /* No Self Pings */ //Pass the variable by reference to the function, so the function can modify the variable. function no_self_ping (&$links) { $home = get_option( 'home' ); foreach ( $links as $l => $link ) //Find the position of the first occurrence of a substring in a string. //($a === $b) Identical operator. TRUE if $a is equal to $b, and they are of the same type. if ( 0 === strpos( $link, $home ) ) //Unset the variable unset($links[$l]); } //Hooks the function to the specific action (pre_ping) add_action( 'pre_ping', 'no_self_ping' ); |
Leave a Reply