Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Dan Rossiter

    (@danrossiter)

    Hi RoyKok,

    To do what you want, all you should need to do is add this to your theme’s functions.php file.

    function dg_target_blank(){ ?>
    <script type="text/javascript">
      jQuery(document).ready( function(){
          jQuery('.document-icon > a').attr('target', '_blank');
      } );
    </script>
    <?php }
    add_action( 'wp_print_footer_scripts', 'dg_target_blank' );

    I’m going to mark this as resolved, but please let me know if you run into any snags.

    -Dan

    Thread Starter RoyKok

    (@roykok)

    Thank you Dan, It will be a few days till I can give it a try. Thanks for the great support!

    Roy

    I inserted this code as instructed and it does not open my PDF in a new window. Any other suggestions?

    https://www.chalkflewup.com (look under library page).

    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi chalkflewup,

    If you look at the source on that page, you’ll see “<!– No attachments to display. How boring! ?? –>,” which is printed by Document Gallery when no documents match whichever parameters it’s been given. Which shortcode are you using? If it’s the bare one that looks like this: [dg], then be sure all of the documents that you want displayed are attached to the page where the shortcode is used. This can be done by using the “Add Media” button on whichever post/page you want the gallery to be displayed on OR by going to the main Media page in your dashboard and setting the “uploaded to” value for anything that doesn’t already have a page/post assigned.

    Please let me know if you’re still having issues after you’ve done the above and I’ll be happy to work with you more!

    -Dan

    PS: If you’ve found this plugin useful, please take a moment to rate it. Thanks! ??

    Thanks for the speedy reply. I’m following the steps — inserted the code into the functions.php file. My source in the WP editor looks like so…

    [dg] USTA Training Phases for Kids

    And it’s not opening in a new window.

    Thoughts?

    Plugin Author Dan Rossiter

    (@danrossiter)

    chalkflewup,

    The code you inserted is working fine. If you look at the source for the page, you’ll see the JavaScript is being printed at the bottom of the page.

    The issue is that you don’t have any attachments that are being matched so the gallery is not generating any icons. If you had icons, they would be opening in a new page.

    It looks like you’re directly inserting some document on that page, which will not (and should not) be affected by the JavaScript I’ve provided. If you take a look at the video I put together on the Document Gallery home page, that should clarify how to include documents within the gallery.

    -Dan

    PS: If you’ve found this plugin useful, please take a moment to rate it. Thanks! ??

    Greetings! I added this code to my theme’s functions.php and my site goes blank. Should I enter it exactly as you have posted here or is there a script I’m missing?

    Plugin Author Dan Rossiter

    (@danrossiter)

    Hi trinitywebdesign,

    What you describe sounds like you may not have an opening PHP tag before the code (i.e.: <?php). If you’re using that block as the only content of your functions.php, you’ll need to prefix it all with <?php.

    Please let me know if that doesn’t solve your problem so we can keep working to figure out what’s going on.

    -Dan

    PS: If you’ve found this plugin useful, please take a moment to rate it. Thanks! ??

    Thanks! This was a helpful thread. Feature suggestion –?make this target _blank functionality available as a setting or preferably, as a short code parameter ?? Thanks for all your great work on this plugin. On my way to add my rating ??

    I added the above code into my theme’s functions.php, but no dice.

    Plugin Author Dan Rossiter

    (@danrossiter)

    enodoglobal,

    Can you elaborate on that? I’ve looked at the page you linked to from your other thread and this is not running on that site.

    -Dan

    This thread answered my question. I second joelrandell’s suggestion to make this a setting option or short code parameter. I’ve rated this plugin and want to add my personal thanks, Dan, for all the work this plugin saved me. It creates a very neat appearance on the page.

    And another big thank you for this code.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Open Document in New Window’ is closed to new replies.