1. Halo Guest, pastikan Anda selalu menaati peraturan forum sebelum mengirimkan post atau thread baru.

[ASK] Edit Follow pada settingan nofollow otomatis

Discussion in 'Wordpress' started by ulumdell, Feb 19, 2016.

  1. ulumdell

    ulumdell Ads.id Fan

    Joined:
    Jun 2, 2011
    Messages:
    193
    Likes Received:
    8
    Location:
    surakarta
    Salam,

    Saya ada kendala untuk merubah link klien menjadi follow.



    pada functions.php saya sematkan kode otomatis untuk membuat link keluar menjadi nofollow.


    /* ----------------------------------------------------
    Link Keluar Menjadi Nofollow
    -------------------------------------------------------
    */
    add_filter('the_content', 'my_nofollow');
    add_filter('the_excerpt', 'my_nofollow');
    function my_nofollow($content) {
    return preg_replace_callback('/<a[^>]+/', 'my_nofollow_callback', $content);
    }
    function my_nofollow_callback($matches) {
    $link = $matches[0];
    $site_link = get_bloginfo('url');
    if (strpos($link, 'rel') === false) {
    $link = preg_replace("%(href=\S(?!$site_link))%i", 'rel="nofollow" $1', $link);
    } elseif (preg_match("%href=\S(?!$site_link)%i", $link)) {
    $link = preg_replace('/rel=\S(?!nofollow)\S*/i', 'rel="nofollow"', $link);
    }
    return $link;
    }


    untuk exclude link url biar menjadi follow, bagaimana merubah kode tersebut sehingga link klien mejadi follow.
     

Share This Page