Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #446140

    Hi, I have my posts load in a new window with no sidebars, footer information, header and title settings. All I want to do is to add a “close window” button at the beginning and end of each post for the user to click and close that window. Is this possible?

    Thank you

    #446603

    Hey George!

    See here, http://stackoverflow.com/questions/8057802/html-button-close-window.

    If you want it on all posts then you can try adding it to the single.php file on lines 31 and 48.

    Best regards,
    Elliott

    #446611

    Ok thanks, that’s helpful. I just realised that I could create a nice button through the advanced layout editor shortcut. Is there a way to add the shortcut code that it creates to the single.php page?

    #447522

    Hi!

    If you use the button shortcode, you won’t be able to add the onclick attribute as suggested on the previous post. You need to create a custom code then you can apply the button shortcode style to it. Use google inspector or firebug to get the css codes for the button shortcode. This is the css code of the small button shortcode:

    body div .avia-button {
      border-radius: 3px;
      padding: 10px;
      font-size: 12px;
      text-decoration: none;
      display: inline-block;
      border-bottom-style: solid;
      border-bottom-width: 1px;
      margin: 3px 0;
      line-height: 1.2em;
      position: relative;
      font-weight: normal;
      text-align: center;
      max-width: 100%;
      color: #ffffff;
      border-color: #0b3a66;
        background-color: #2d5c88;
    }

    Best regards,
    Ismael

    #447852

    Ok thanks for your answer! I would like to point out though that it is possible to do it. What I did was that I added this code at the end of my child theme’s functions.php file:

    // Add close window functionality
    function add_custom_script(){
    ?>
    <script>
    (function($){
        $(window).load(function() {
        	$('.close-window .avia-button').on('click', function(){
    				 window.open('', '_self', '');
                     window.close();
            });
        });
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');

    Then I added my button through the visual editor and added the close-window css class into the custom CSS field.

    Then in my single.php template file I used the do_shortcode wordpress function and I copied the shortcode created from the visual editor and pasted like this escaping the ‘ character:

    <?php echo do_shortcode('[av_button label=\'Close window\' link=\'manually\' link_target=\'\' size=\'small\' position=\'center\' icon_select=\'yes\' icon_hover=\'aviaTBicon_hover\' icon=\'ue813\' font=\'entypo-fontello\' color=\'theme-color\' custom_bg=\'#444444\' custom_font=\'#ffffff\' custom_class=\'close-window\']'); ?>

    Thanks again for your help!

    #449361

    Hi!

    Glad you figured out a way to add it dynamically. :)

    Best regards,
    Ismael

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Close window button for all posts’ is closed to new replies.