Title: Json 403
Last modified: October 27, 2022

---

# Json 403

 *  Resolved [NAROLLES](https://wordpress.org/support/users/narolles/)
 * (@narolles)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/json-403/)
 * Hello Hector
    Glad to see you again….
 * I’m watching your evolutions for elementor….I’ll try to move forward by looking
   at the posts concerned when I can focus on it. If one day you have the idea of
   making a turnkey solution .. it will be great.
 * For the past few days, I have encountered an error that is not permanent….maybe
   it comes from WPP, but maybe from elsewhere
    I see this error: Failed to load
   resource: the server responded with a status of 403 () /wp-json/wordpress-popular-
   posts/v1/popular-posts
 * Finally incidentally How can I put with this short code [wpp_counter_view] the
   expression “views” just after … currently I tinker
 * Thank you and good continuation
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fjson-403%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/json-403/#post-16139408)
 * Hi [@narolles](https://wordpress.org/support/users/narolles/),
 * > For the past few days, I have encountered an error that is not permanent….maybe
   > it comes from WPP, but maybe from elsewhere
   >  I see this error: Failed to load
   > resource: the server responded with a status of 403
 * This might be caused by the WP Rocket plugin. Please see [Is WordPress Popular Posts compatible with caching plugins?](https://github.com/cabrerahector/wordpress-popular-posts/wiki/5.-FAQ#is-wordpress-popular-posts-compatible-with-caching-plugins)
   and make sure to follow the recommendations listed there.
 * > How can I put with this short code [wpp_counter_view] the expression “views”
   > just after
 * Assuming you’re talking about [this function](https://wordpress.org/support/topic/count-viewer-afterr-update-no-work/),
   all you need to do is to add the “views” text after the views count, like so 
   for example:
 *     ```
       function wpp_viewcounter ($option) {
           if (function_exists("wpp_get_views") ) {
               $nbView = wpp_get_views(get_the_ID(), 'all');
               $iNbView = intval(preg_replace("/[^0-9]/", "", $nbView));
               return colorCounterView($iNbView) . ' views';
           }
       }
       add_shortcode('wpp_counter_view', 'wpp_viewcounter');
       ```
   
 *  Thread Starter [NAROLLES](https://wordpress.org/support/users/narolles/)
 * (@narolles)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/json-403/#post-16142112)
 * Hi Hector
 * **For the function….**
 *     ```
       I adapted this existing function instinctively
       it works
       just how to put a space between the number and the "views" label
       if I was more manic I would put an option to put the label in the singular when there is only one view....but hey, we can do without it.....
       can you confirm me the writing of the last line Thank you
       ```
   
 * `
    function wpp_viewcounter ($option) { if (function_exists(‘wpp_get_views’) ){
   $nbView = wpp_get_views(get_the_ID()); $iNbView = intval(preg_replace(“/[^0-9]/”,””,
   $nbView)); echo colorCounterView($iNbView); } } add_shortcode(‘wpp_counter_view’,‘
   wpp_viewcounter’); function colorCounterView($number) { $counterColorBegin=””;
   $counterColorEnd=””; $num= intval(preg_replace(“/[^0-9]/”,””,$number)); if ($
   num >100) { $counterImportant = “”; if ($num >100) {$counterImportant = ‘-normal’;}
   if ($num >300) {$counterImportant = ‘-good’;} if ($num >500) {$counterImportant
   = ‘-verygood’;} if ($num >1000) {$counterImportant = ‘-important’;} if ($num 
   >2000) {$counterImportant = ‘-veryimportant’;} $counterColorBegin='<span class
   =”eye-counter-color’.$counterImportant.'”>’; $counterColorEnd='</span>’; } else{
   if (strlen($number)> 4) { $counterImportant = ‘-veryimportant’; $counterColorBegin
   ='<span class=”eye-counter-color’.$counterImportant.'”>’; $counterColorEnd='</
   span>’; } } return $counterColorBegin . $number . $counterColorEnd . $iNbView.‘
   vues’;
 *  }
 *  Plugin Author [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * (@hcabrera)
 * [3 years, 7 months ago](https://wordpress.org/support/topic/json-403/#post-16143482)
 * There are a few issues with your code so I took the liberty to clean it up a 
   bit. Also added some code lines to make sure that the views count is displayed
   correctly (singular vs plural).
 * Have a look:
 *     ```
       function wpp_viewcounter($option)
       {
           if ( function_exists('wpp_get_views') )
           {
               $nbView = wpp_get_views( get_the_ID() );
               $iNbView = intval( preg_replace("/[^0-9]/", "", $nbView) );
               return colorCounterView($iNbView);
           }
       }
       add_shortcode( 'wpp_counter_view', 'wpp_viewcounter' );
   
       function colorCounterView($number)
       {
           $counterColorBegin = "";
           $counterColorEnd = "";
           $num = intval( preg_replace("/[^0-9]/", "", $number) );
   
           if ( $num > 100 )
           {
               $counterImportant = "";
               if ($num >100) {$counterImportant = '-normal';}
               if ($num >300) {$counterImportant = '-good';}
               if ($num >500) {$counterImportant = '-verygood';}
               if ($num >1000) {$counterImportant = '-important';}
               if ($num >2000) {$counterImportant = '-veryimportant';}
   
               $counterColorBegin ='<span class="eye-counter-color' . $counterImportant .'">';
               $counterColorEnd = '</span>';
           }
           else {
               if ( strlen($number) > 4 ) {
                   $counterImportant = '-veryimportant';
                   $counterColorBegin ='<span class="eye-counter-color' . $counterImportant .'">';
                   $counterColorEnd ='</span>';
               }
           }
   
           $views = sprintf(
               _n('%s view', '%s views', $number, 'wordpress-popular-posts'),
               $number
           );
   
           return $counterColorBegin . $views . $counterColorEnd;
       }
       ```
   

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Json 403’ is closed to new replies.

 * ![](https://ps.w.org/wordpress-popular-posts/assets/icon-256x256.png?rev=1232659)
 * [WP Popular Posts](https://wordpress.org/plugins/wordpress-popular-posts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wordpress-popular-posts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wordpress-popular-posts/)
 * [Active Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wordpress-popular-posts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wordpress-popular-posts/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Hector Cabrera](https://wordpress.org/support/users/hcabrera/)
 * Last activity: [3 years, 7 months ago](https://wordpress.org/support/topic/json-403/#post-16143482)
 * Status: resolved