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?

closed as off-topic by birgire, Pieter Goosen, Pat J, gmazzap, Johannes Pille Sep 28 '14 at 12:34

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question should be specific to WordPress. Generic PHP/JS/HTML/CSS questions might be better asked at Stack Overflow or another appropriate site of the Stack Exchange network. Third party plugins and themes are off topic." – birgire, Pieter Goosen, Pat J, gmazzap, Johannes Pille
If this question can be reworded to fit the rules in the help center, please edit the question.


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');

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');

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