• Resolved ocean_jasper

    (@ocean_jasper)


    Here is the code that you provided elsewhere (here) to allow PDFs to open in a new window:

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

    Another post on this site (“How to add codes in function.php“) advises I should just add it to the end of the function.php file. When I did this and updated, the window went white, WordPress wouldn’t load, and I had to go to my server to restore my function.php file to its original.

    Based on a video tutorial I found, I tried created a my_function.php document and adding it here. The function.php successfully called up my_function.php, but the Document Gallery code simply didn’t execute.

    So then I tried deleting “<?php” from the beginning of my text insertion. Again I got the white screen, and had to go to my server.

    As an aside, I am running the Dynamix theme. My webpage is here. I had to remove the additional code but at least you can see the links.

    As may be obvious, I am an absolute novice and know nothing about coding. I’ve already read the entire other post and understood as much as I could. Would appreciate help on this!!

    https://wordpress.org/plugins/document-gallery/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author demur

    (@demur)

    Hi ocean_jasper!

    It seems You are almost there.
    According to the provided link I can see that Document Gallery plugin couldn’t catch any attachment added to the post.
    Solution can be one of these steps:
    * You can use shortcode with option [dg localpost=false] to display all the attachments through Your WordPress instance in the gallery
    * You can attach documents directly to the stated post
    * You can specify IDs of desirable attachments [dg ids=10,2,4,42] (mentioned IDs only as an example, You have to determine Yours)

    To attach a document You can either go to the post You want it attached to and upload directly from there. If the documents are already uploaded, You’ll need to go to Dashboard -> Media and the documents You want to attach will (hopefully) have an “Attach” option under the “Uploaded to” column. You have to click that and select the post you want the documents to be displayed at.

    If you are certain that the script will not interfere with other plugins, you can also just take the script and place it in your theme’s footer.php file which will load it at the bottom of every page.

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

    A little cumbersome but it does work.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Open PDF in new window’ is closed to new replies.