WordPress.org

Ready to get started?Download WordPress

Forums

Modify "Popularity Contest" plugin (5 posts)

  1. kirkward
    Member
    Posted 5 years ago #

    I am using the "Popularity Contest" plugin along with the "Exclude Pages from Navigation" plugin. Both are working well, as designed.

    However, the popularity contest measures and displays pages in it that I have designated to be omitted from the navigation through the exclude from navigation plugin.

    Can someone instruct me on a way to remove either specific pages, or groups of pages from display by the popularity contest functions?

    Thanks in advance,
    Kirk Ward

  2. t3hhu1k
    Member
    Posted 5 years ago #

    I've been looking for an answer to this, too. :/

  3. Zack Katz
    Member
    Posted 5 years ago #

    You need to edit popularity-contest.php like this:

    Around line 1383, there is the following code:

    WHERE post_status = 'publish'

    add AFTER it:

    AND post_type = 'post'

    It should look like this in the end:

    WHERE post_status = 'publish'
    AND post_type = 'post'
    AND post_date < NOW()
  4. jbiesnecker
    Member
    Posted 5 years ago #

    Hacking on the plugin code isn't a particularly good idea (for instance, when you upgrade you have to port all of your changes to the new version).

    Popularity Contest supports filters, so you can define behavior like that outside of the plugin. To get rid of pages in almost all functions (which is, I think the behavior most people want) you can add:

    add_filter('posts_where', 'limit_pc_posts', 10, 0);
    function limit_pc_posts() {
    	return " AND post_type = 'post' ";
    }

    somewhere in your template (I normally include a custom PHP file in all of my themes so I can add/remove things like this.

    HTH

  5. maxoud
    Member
    Posted 4 years ago #

    The code from jbiesnecker breaks the whole blog on 2.8.6. May be because of custom queries I use?

Topic Closed

This topic has been closed to new replies.

About this Topic