snovapavel,
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/styles/default.min.css">
<style>
pre {
width: 300px;
overflow: auto;
}
</style>
</head>
<body>
<pre class="color"><code class="PHP">function updateNumbers() {
global $wpdb;
$querystr = "SELECT $wpdb->posts.* FROM $wpdb->posts WHERE $wpdb->posts.post_status = 'publish' AND $wpdb->posts.post_type = 'post' ";
$pageposts = $wpdb->get_results($querystr, OBJECT);
$counts = 0 ;
if ($pageposts):
foreach ($pageposts as $post):
setup_postdata($post);
$counts++;
add_post_meta($post->ID, 'incr_number', $counts, true);
update_post_meta($post->ID, 'incr_number', $counts);
endforeach;
endif;
}
add_action ( 'publish_post', 'updateNumbers' );
add_action ( 'deleted_post', 'updateNumbers' );
add_action ( 'edit_post', 'updateNumbers' );</code></pre>
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.1.13/jquery.mousewheel.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.2.0/highlight.min.js"></script>
<script>
// По отдельности работают на Ура, вместе — никак...
// Активация горизонтальной прокрутки
jQuery('.PHP')
.data('scrollLeft', -1)
.mousewheel(function(event, delta) {
var left = jQuery(this).data('scrollLeft');
left -= (delta*50);
this.scrollLeft = left;
jQuery(this).data('scrollLeft', left);
return false;
});
// Активация подсветки кода
hljs.initHighlightingOnLoad();
</script>
</body>
</html>