wordpress添加键盘支持左右翻页

将以下代码放引入在header.php或者footer.php中

<!--键盘左右翻页-->
<?php wp_reset_query();if (is_home() || is_archive() || is_search()) { ?>   
<script type="text/javascript">   
    document.onkeydown = chang_page;function chang_page(e) {   
        var e = e || event,   
        keycode = e.which || e.keyCode;   
        if (keycode == 33 || keycode == 37) location = '<?php echo get_previous_posts_page_link(); ?>';   
        if (keycode == 34 || keycode == 39) location = '<?php echo get_next_posts_page_link(); ?>';   
    }      
</script>   
<?php } ?>    
<?php wp_reset_query();if (is_single()) { ?>   
<script type="text/javascript">   
document.onkeydown = chang_page;function chang_page(e) {   
    var e = e || event,   
    keycode = e.which || e.keyCode;      
    if (keycode == 33 || keycode == 37) location = '<?php echo get_permalink(get_adjacent_post(false, '', false)); ?>';      
    if (keycode == 34 || keycode == 39) location = '<?php echo get_permalink(get_adjacent_post(false, '', true)); ?>';      
}      
</script>      
<?php } ?>   
<!--键盘左右翻页 end-->

发布日期:

所属分类: Wordpress 综合 标签:


没有相关文章!