If you’re using WordPress as a CMS and don’t want to muddy up your head tag code, you can add this cdoe as an alternative to adding the wp_head(); call. It condenses WordPress Popular Posts database update ajax post function wp_head hook into a single line.
<?php if (is_single() || is_page()): ?>
<script type="text/javascript">$.post('<?php echo admin_url('admin-ajax.php'); ?>', {action: 'wpp_update', token: '<?php echo wp_create_nonce('wpp-token'); ?>', id: <?php global $wp_query; echo $wp_query->post->ID; ?>});</script>
<?php endif; ?>
If you’re using WordPress as a CMS and don’t want to muddy up your head tag code, you can add this cdoe as an alternative to adding the wp_head(); call. It condenses WordPress Popular Posts database update ajax post function wp_head hook into a single line.
<?php if (is_single() || is_page()): ?>
<script type="text/javascript">$.post('<?php echo admin_url('admin-ajax.php'); ?>', {action: 'wpp_update', token: '<?php echo wp_create_nonce('wpp-token'); ?>', id: <?php global $wp_query; echo $wp_query->post->ID; ?>});</script>
<?php endif; ?>