1. Home
  2. ReHub Theme
  3. Advanced tips and customizations
  4. How to fix post view script

How to fix post view script

Some servers can block execution scripts for post view. Maybe you have security plugin, so, you must add file https://site.com/wp-content/themes/rehub/functions/rhpostviewcounter.php to whitelist or maybe rehubpostviews action to whitelist.

Also, it’s possible to place file in root folder, usually it helps

Take file rehub-ajax.php from Rehub framework plugin/includes/ and place it in root folder of your site, open it and change

require_once('../../../../wp-load.php');

to

require_once('wp-load.php');

In your grandchild plugin functions file (or in child theme functions) add next code

/ Change path to Post view counter /
function rehub_postview_enqueue() {
global $post;
if ( is_single()) {
wp_register_script( 'rehub-postview', get_template_directory_uri() . '/js/postviews.js', array( 'jquery' ) );
wp_localize_script( 'rehub-postview', 'postviewvar', array('rhpost_ajax_url' => '/rehub-ajax.php', 'post_id' => intval($post->ID)));
wp_enqueue_script ( 'rehub-postview');
}
}

You must have enough customization skills for such actions, because if you will do something wrong, your site can be broken

How to customize theme