WordPress.org

Ready to get started?Download WordPress

Forums

WordPress.com Stats
Ignore Visits to Page or Post (6 posts)

  1. bransonsparks
    Member
    Posted 3 years ago #

    It would be great to be able to specify on the configuration page post IDs that wp-stats should not track. This is a snippet that I added into the stats.php file to ignore a specific page, which I use as a homepage.

    //here is a fun thing to keep the homepage from being tracked
    	if ( $a['post'] == "1565" ){
    	echo ('<p style="text-align:center">not tracked</p>');
    	return;
    }
    //this is the end of the fun thing to keep the homepage from being tracked

    I drop that in around line 110 in stats.php, in the stats_footer function. Works great, but I have to add it in at every update!

    http://wordpress.org/extend/plugins/stats/

  2. jjsulzbach
    Member
    Posted 3 years ago #

    I also needed to exclude the homepage from the get_stats_csv returns, but I needed to avoid editing the original function.

    So I wrote a wrapper function and posted it in the "Hacks" forum at:

    http://wordpress.org/support/topic/stats-plugin-excluding-homepage-from-stats_get_csv-results?replies=1#post-1721505

    Maybe it might help someone.

  3. Renji
    Member
    Posted 2 years ago #

    @bransonsparks Can this be used to ignore multiple pages or posts?

  4. bransonsparks
    Member
    Posted 2 years ago #

    I should think so.
    Try this:
    if ( $a['post'] == "page1" || "page2" || "page3" ){

    etc.

  5. bransonsparks
    Member
    Posted 2 years ago #

    ...whoops, with the rest of the code from above. I don't know if the plugin code has changed since I posted this nearly a year ago. I know that WPStats runs through Jetpack now.

    I'm not using this hack anymore; I ditched my personal homepage.

  6. Renji
    Member
    Posted 2 years ago #

    I am still able to show popular posts, based on views, on my website using the old WP stats code. Want to prevent a couple of pages from showing up in that list. Let me see if it works.

    Thanks.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags