WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. benallfree
    Member
    Posted 9 months 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;
    });

    http://wordpress.org/plugins/wordpress-popular-posts/

  2. benallfree
    Member
    Posted 9 months ago #

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

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.