• Resolved FmX

    (@nescafe89)


    Hello, how to exclude counting for certain pages, for example Woocommerce pages for oder, store etc.

    Thank you

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

    (@hcabrera)

    Hey @nescafe89,

    You could add something like this to your theme’s functions.php file.

    Note that you may need to change the is_product() conditional tag to something else (see WooCommerce Conditional Tags for reference) to make that code snippet fit your particular needs.

    Thread Starter FmX

    (@nescafe89)

    Thanks i will try. For now for widget i put exclude ids, but in general would be good to exluclude all woocommerce stuff with checkbox in settings or simillar settings.

    Plugin Author Hector Cabrera

    (@hcabrera)

    For now for widget i put exclude ids

    That’s not going to work. Visits to your WooCommerce pages will still register even if the widget is not on page.

    If you want WPP to not count visits to the shop page, the cart page, the checkout page, or the user account page then this is what you want to add to your theme’s functions.php:

    add_filter('wp_script_attributes', function($atts) {
    if (
    ( is_shop() || is_cart() || is_checkout() || is_account_page() )
    && (str_contains($atts['src'], 'wpp.js') || str_contains($atts['src'], 'wpp.min.js'))
    ) {
    $atts['src'] = '';
    }

    return $atts;
    });

    If you’re using a caching plugin on your site you may have to clear its page cache for these changes to take effect.

    Thread Starter FmX

    (@nescafe89)

    Thank you very much, I added it, now we will see if it will be included in the statistics. Will the file functions.php be updated when the theme is updated ?

    Plugin Author Hector Cabrera

    (@hcabrera)

    Will the file functions.php be updated when the theme is updated ?

    Yes, WordPress will automatically replace all theme files with the new ones, including functions.php.

    To keep your changes do any of the following:

    • Install the Code Snippets plugin (if you haven’t done so already), and then use it to add the code snippet from my previous comment to your site.
    • Create a Child Theme, then add that code to the child theme’s functions.php file.
    Thread Starter FmX

    (@nescafe89)

    Ok thank you

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

The topic ‘How to exclude certain posts’ is closed to new replies.