WordPress Popular Posts
[resolved] Proposed modification: add instance variables filter to get_popular_posts() (2 posts)

  1. benallfree
    Posted 2 years ago #

    Hello, I have a modification proposal to add an instance variable filter to get_popular_posts().

    I needed to modify the post_type query to include some custom post types so popular posts would show. Not finding an existing filter, I thought this to be the best place to add one:

    function get_popular_posts($instance, $return = false) {
    // update instance's settings
    $instance = $this->array_merge_recursive_distinct($this->defaults, $instance);
    $instance = apply_filters('wpp_instance', $instance);

    That way, in my own plugin, I can do this:

    add_filter('wpp_instance', function($instance) {
    $instance['post_type'] .= ',gallery';
    return $instance;


  2. benallfree
    Posted 2 years ago #

    Nevermind, wpp_get_mostpopular() accepts post_type as an argument. Sorry.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WordPress Popular Posts
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic


No tags yet.