Viewing 1 replies (of 1 total)
  • Thread Starter Duke

    (@dukessa)

    Nevermind, I wrote the code myself.

    For anyone interested, place in your template <head> (since the footer gets wiped out by PF):

    <?php if(is_singular('slug-of-post-type')) :
    	global $post;
            $p_type = get_post_type(get_the_ID());
            ?>
            <script type="text/javascript">
                jQuery(document).ready(function() {
                    $( ".printfriendly a" ).click(function() {
                        $("#pf-core").load(function() {
                            setTimeout( function () {
                                $('#pf-core').contents().find('iframe').contents().find('#pf-print-area').addClass("pf-<?php echo $p_type; ?>");
                            }, 1000 );
                        });
                    });
                });
            </script>
    <?php endif; ?>

    You can lower the milliseconds (1000 by default), if you see a big delay in the way the style is applied, however I dont advise to keep it too low, since the second iFrame will take *a little* time to load anyway… and if the script fires too soon, the style won’t be applied at all.

    GIST Snippet here

Viewing 1 replies (of 1 total)
  • The topic ‘Add body_class to iframe or dynamically add class references’ is closed to new replies.