Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The Jetpack image widget does not offer a target option for links. Is there a way to open all Jetpack image widget links in a new window without hacking the plugin? Like through a hook or function?

share|improve this question

2 Answers 2

up vote 1 down vote accepted

There is no hook available in the plugin.

One solution is to simply copy this Jetpack Widget and add the target option.

Another is through jQuery, in the file /theme/functions.php:

add_action( 'wp_enqueue_scripts', 'jetpack_widget_wpse_88067' );

function jetpack_widget_wpse_88067() 
        get_stylesheet_directory_uri() . "/js/jethack.js", 
        array( 'jquery'), // dependencies
        false, // version
        true // in footer

And in the file /theme/js/jethack.js:

jQuery(document).ready(function($) {   
    $('.jetpack-image-container a').attr('target','_blank');
share|improve this answer

Another option would be to add this to your home.php

<script type="text/javascript">
jQuery(document).ready( function($) {
  jQuery('.widget_image a').attr('target', '_blank');
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.