Support » Plugin: WP Gallery Custom Links » Caption as no-follow link ?

  • Resolved kreativito

    (@kreativito)


    I love it.

    Is it also possible to add a no-follow link to the Caption text ?
    I would love to have the possibility to show for each image a link that is a no-follow link, but gives photo credits.

    Right below the image.

    The font should be very small.

    If I would just know how to do it ?
    And where I would need to change the code ?

    I would immediately try it.

    Here are my tests showing my problem and what I would like to achieve.
    Arthalla

    thank you so much for every little help !

    https://wordpress.org/plugins/wp-gallery-custom-links/

Viewing 8 replies - 1 through 8 (of 8 total)
  • Captions are a part of WordPress core, and if you’re using the most recent version of WordPress, you should be able to add your own links and set the no follow property yourself directly.

    Regarding the link around the gallery images, there’s no way currently to set that property directly, but one workaround may be to use jQuery to set the property on each gallery link, something like:

    jQuery('.gallery-item a').attr('rel','nofollow');

    (Code above not tested, just an idea).

    Marking this resolved due to no further response from original poster.

    Hi. Is it possible to integrate the attribute on the UI , the same way as “Target” select option?

    or if you can please tell how and where to hardcode to have this feature available trhough shortcode.

    thanks a lot for such a cleaver simplest tool for making default gallery a very usefull tool.
    I found it great for parthners logo zone.

    a bad solution I found right now is hardcoding
    wp-gallery-custom-links.php in plugin’s folder
    at row #417 says
    $output = preg_replace( $needle, 'href="' . $custom_link . '"', $output );
    changed to
    $output = preg_replace( $needle, 'href="' . $custom_link . '" rel="nofollow"', $output );

    but would be great to allow to ADD OR NOT the rel="nofollow" through UI or shortcode.

    thanks again

    As mentioned above, there’s no direct way to do this through the plugin, but you could use the jQuery method mentioned above, or if you want to have it directly in the page source without javascript, you could try using the plugin’s filter in your functions.php file, something like this:

    add_filter( 'wpgcl_filter_raw_gallery_link_url', 'my_gallery_link_url_filter', 10, 3 );
    function my_gallery_link_url_filter( $link, $attachment_id, $post_id ) { return $link . '" rel="nofollow'; }

    I haven’t tested this extensively, but it might work for simple cases, and if your links don’t already have rel tags on them.

    Adding a separate “rel” attribute in the UI would add clutter to the UI and a performance hit to the plugin for a case that doesn’t come up for very many people, so it’s not something I’m really looking at adding. But hopefully the filter or jQuery method will suffice for your site.

    hi, thanks for your fast and sincere answer.
    I understand that is not for everybody feature.

    Anyway I have an small and nice solution.

    *** HACK TO SHORTCODE NOFOLLOW ***
    1) EDIT wp-gallery-custom-links.php in plugin’s folder ADDING this on row #264

    if( isset( $attr['open_all_in_new_window_no_follow'] ) && strtolower( trim( $attr['open_all_in_new_window_no_follow'] ) ) === 'true' ) {
    				$target = '_blank" rel="nofollow';
    			}

    2) SHORTCODE ON WP PAGE/POST EDIT (TEXT VIEW)
    example
    [gallery ids="23,20,201,199" open_all_in_new_window_no_follow="true"]

    works like a charm
    hope this help somebody

    The filter solution posted above will also add it into the source directly without having to modify the plugin code, but whatever works! 🙂

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Caption as no-follow link ?’ is closed to new replies.