Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Hector Cabrera

    (@hcabrera)

    Hi there!

    Could you please advise how to prevent from counting views on Customizer?

    The plugin doesn’t count views when previewing a post the “regular” way (that is, by clicking on the Preview link in the Post edit screen). Bad news is that WPP doesn’t check for previews in customizer since this is a new-ish WordPress feature (and I wasn’t really aware that it was even possible to preview posts / pages from the Customizer, I honestly don’t use it that much).

    With that being said, to prevent WPP from counting views on Customizer:

    1. Go to Plugins > Editor and pick WordPress Popular Posts from the dropdown at the right.
    2. Find:
      if ( is_singular($trackable) && !is_front_page() && !is_preview() && !is_trackback() && !is_feed() && !is_robots() ) {

      … and add the is_customize_preview() conditional tag like so:

      if ( is_singular($trackable) && !is_front_page() && !is_preview() && !is_trackback() && !is_feed() && !is_robots() && !is_customize_preview() ) {

    3. Hit the Update file button to apply changes.

    I’ll make sure to include this change in the next release of the plugin, so thanks for the notice!

    And in the same time log both visitors and logged in users?

    Easy: go to wp-admin > Settings > WordPress Popular Posts > Tools and change the “Log views from” option to Everyone.

    Thread Starter Alex

    (@flyjam)

    Thank you for the quick help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Prevent logging views from Customizer’ is closed to new replies.